Skip to content

fix: Guard against conn leak after server close #1

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

Closed
wants to merge 1 commit into from

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Apr 4, 2023

Noticed this leak as part of coder/coder#7004

See: https://github.com/coder/coder/actions/runs/4609297757/jobs/8146257114?pr=7004

NOTE: This is mainly a problem when using Serve, which we were not previously using in coder. However, our previous implementation of starting multiple goroutines for each connection were not ideal either. This fix + usage of Serve should reduce overhead/memory usage when there are many connections.

We will also be looking to refactor the implementation as part of coder/coder#6177.

@@ -124,3 +126,104 @@ func TestServerClose(t *testing.T) {
return
}
}

func TestServerClose_ConnectionLeak(t *testing.T) {
Copy link
Member Author

@mafredri mafredri Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is a bit finicky, but without the fix it will usually time out (as a proof of the issue being fixed).

@mafredri mafredri marked this pull request as ready for review April 4, 2023 17:51
@mafredri mafredri self-assigned this Apr 4, 2023
@mafredri mafredri requested review from coadler and kylecarbs April 4, 2023 17:51
@mtojek
Copy link
Member

mtojek commented May 12, 2023

Hey @mafredri! Is this PR still valid?

@mafredri
Copy link
Member Author

@mtojek It doesn't necessarily hurt but it's not needed anymore, this was fixed in another way in the agentssh package.

Ultimately a more invasive reactor would be better here e.g. if we wanted to contribute it upstream.

@mtojek
Copy link
Member

mtojek commented May 12, 2023

Thank you for the quick reply and explanation! I will resolve this one.

@mtojek mtojek closed this May 12, 2023
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.

4 participants