Skip to content
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

fix: Avoid use of r.Context() after r.Hijack() #1978

Merged
merged 6 commits into from
Jun 3, 2022

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jun 2, 2022

This PR changes how we initialize websocket.NetConns so that we have a context that emits connection closure.

Fixes #1508

  • fix: Fix goroutine leak by propagating websocket closure
  • fix: Use of r.Context() in workspaceAgentDial
  • fix: Use of rw and r.Context() in workspaceAgentListen
  • fix: Use of r.Context() in workspaceAgentPTY

This is version 2. Initially I implemented io.EOF closure propagation in coderd/turnconn.Conn, while I do think it may be a good idea, it's not necessary to fix #1508. I implemented it this way so that the fix can be utilized in the other handlers as well.

@mafredri mafredri self-assigned this Jun 2, 2022
@mafredri mafredri requested a review from a team June 2, 2022 12:47
coderd/workspaceagents.go Outdated Show resolved Hide resolved
coderd/workspaceagents.go Outdated Show resolved Hide resolved
coderd/workspaceagents.go Outdated Show resolved Hide resolved
@kylecarbs
Copy link
Member

An absolutely awesome fix @mafredri!

@mafredri mafredri force-pushed the mafredri/fix-goroutine-leak branch from 3f8c815 to 9e6727e Compare June 3, 2022 09:36
@mafredri mafredri merged commit b4f5920 into main Jun 3, 2022
@mafredri mafredri deleted the mafredri/fix-goroutine-leak branch June 3, 2022 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Goroutine leak in coderd.(*api).workspaceAgentTurn
4 participants