Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit894b298

Browse files
fix: stop reading closed channel for/watch devcontainers endpoint
Fixes#19372We increase the read limit to 4MiB (we use this limit elsewhere). Wealso make sure to stop sending messages of `containersCh` becomesclosed.
1 parenta9f607a commit894b298

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎coderd/workspaceagents.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,11 @@ func (api *API) watchWorkspaceAgentContainers(rw http.ResponseWriter, r *http.Re
896896
case<-ctx.Done():
897897
return
898898

899-
casecontainers:=<-containersCh:
899+
casecontainers,ok:=<-containersCh:
900+
if!ok {
901+
return
902+
}
903+
900904
iferr:=encoder.Encode(containers);err!=nil {
901905
api.Logger.Error(ctx,"encode containers",slog.Error(err))
902906
return

‎codersdk/workspacesdk/agentconn.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ func (c *AgentConn) WatchContainers(ctx context.Context, logger slog.Logger) (<-
399399
url:=fmt.Sprintf("http://%s%s",host,"/api/v0/containers/watch")
400400

401401
conn,res,err:=websocket.Dial(ctx,url,&websocket.DialOptions{
402-
HTTPClient:c.apiClient(),
402+
HTTPClient:c.apiClient(),
403+
CompressionMode:websocket.CompressionContextTakeover,
403404
})
404405
iferr!=nil {
405406
ifres==nil {
@@ -411,6 +412,8 @@ func (c *AgentConn) WatchContainers(ctx context.Context, logger slog.Logger) (<-
411412
deferres.Body.Close()
412413
}
413414

415+
conn.SetReadLimit(1<<22)// 4MiB
416+
414417
d:=wsjson.NewDecoder[codersdk.WorkspaceAgentListContainersResponse](conn,websocket.MessageText,logger)
415418
returnd.Chan(),d,nil
416419
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp