mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: stop reading closed channel for /watch devcontainers endpoint (#19373)
Fixes https://github.com/coder/coder/issues/19372 We increase the read limit to 4MiB (we use this limit elsewhere). We also make sure to stop sending messages when `containersCh` becomes closed.
This commit is contained in:
@@ -763,7 +763,11 @@ func (api *API) broadcastUpdatesLocked() {
|
||||
func (api *API) watchContainers(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
conn, err := websocket.Accept(rw, r, nil)
|
||||
conn, err := websocket.Accept(rw, r, &websocket.AcceptOptions{
|
||||
// We want `NoContextTakeover` compression to balance improving
|
||||
// bandwidth cost/latency with minimal memory usage overhead.
|
||||
CompressionMode: websocket.CompressionNoContextTakeover,
|
||||
})
|
||||
if err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "Failed to upgrade connection to websocket.",
|
||||
|
||||
Reference in New Issue
Block a user