-
Notifications
You must be signed in to change notification settings - Fork 962
fix: stop reading closed channel for /watch
devcontainers endpoint
#19373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes #19372 We increase the read limit to 4MiB (we use this limit elsewhere). We also make sure to stop sending messages of `containersCh` becomes closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, I'd like to see a unit test or similar that reproduces the condition and validates the fix.
I've added a test in 0ca20dc If you remove the fix in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks OK to me, but I also wonder if there's a way for us to detect us reaching the payload limit and log an error somewhere?
We already do but as a coder/codersdk/wsjson/decoder.go Line 41 in 0ca20dc
|
Ah nice, so we can check for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit, but LGTM, nice work!
@@ -411,6 +412,8 @@ func (c *AgentConn) WatchContainers(ctx context.Context, logger slog.Logger) (<- | |||
defer res.Body.Close() | |||
} | |||
|
|||
conn.SetReadLimit(1 << 22) // 4MiB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: let's add a comment for this, as well as the compression, for posterity.
Re: compression, we might say that we chose nocontexttakeover to improve bandwidth cost/latency with minimal cpu/memory overhead even if contexttakeover has better compression.
Fixes #19372
We increase the read limit to 4MiB (we use this limit elsewhere). We also make sure to stop sending messages of
containersCh
becomes closed.