Skip to content

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

Merged
merged 5 commits into from
Aug 15, 2025

Conversation

DanielleMaywood
Copy link
Contributor

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.

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.
@DanielleMaywood DanielleMaywood marked this pull request as ready for review August 15, 2025 09:55
Copy link
Member

@johnstcn johnstcn left a 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.

@DanielleMaywood
Copy link
Contributor Author

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 coderd/workspaceagents.go you'll be able to test it fails before the fix and passes afterwards.

Copy link
Member

@johnstcn johnstcn left a 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?

@DanielleMaywood
Copy link
Contributor Author

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 debug log

d.logger.Debug(d.ctx, "error reading from websocket", slog.Error(err))

@johnstcn
Copy link
Member

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 debug log

d.logger.Debug(d.ctx, "error reading from websocket", slog.Error(err))

Ah nice, so we can check for StatusMessageTooBig there and scream louder then. 👍 Might be a good separate PR

Copy link
Member

@mafredri mafredri left a 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
Copy link
Member

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.

@DanielleMaywood DanielleMaywood merged commit 205eb29 into main Aug 15, 2025
49 of 52 checks passed
@DanielleMaywood DanielleMaywood deleted the danielle/devcontainers/fix-nasty-bug branch August 15, 2025 11:32
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: devcontainers /watch endpoint reads from empty channel when message over 32KiB is received
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy