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: simplify connection upgrade #2719

Merged
merged 2 commits into from
Sep 24, 2024
Merged

fix: simplify connection upgrade #2719

merged 2 commits into from
Sep 24, 2024

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Sep 24, 2024

  • Unifies inbound/outbound upgrade
  • Adds default timeouts for inbound/outbound upgrades and stream protocol negotation
  • Ensure tcp listener closes sockets when upgrade times out
  • Passes abort signal to connection encrypter
  • Uses simple promise rejection to abort tcp connections

Before:

image

After:

image

Fixes #2537
Fixes #2477

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

- Unifies inbound/outbound upgrade
- Adds default timeouts for inbound/outbound upgrades and stream protocol negotation
- Ensure tcp listener closes sockets when upgrade times out
@achingbrain achingbrain requested a review from a team as a code owner September 24, 2024 14:11
@achingbrain achingbrain merged commit c258b35 into main Sep 24, 2024
23 checks passed
@achingbrain achingbrain deleted the fix/simplify-tcp-upgrade branch September 24, 2024 15:04
@achingbrain achingbrain mentioned this pull request Sep 24, 2024

await attemptClose(maConn, {
Copy link
Contributor

@2color 2color Sep 25, 2024

Choose a reason for hiding this comment

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

Was the source of the problem that attemptClose would close but not abort?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly, it was calling .close which throw if closing gracefully fails, and then call .abort, but we were doing it in response to an error condition so we should just .abort and move on.

As it turns out this hasn't solved the problem completely but it has made it a little better so we're getting closer:

Before:

image

After:

image

I think the bug may be in @libp2p/tls, without it the "inbound pending" count stays near 0 the whole time:

image

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.

investigation: hanging TCPSocketWrap in js-libp2p-amino-dht-bootstrapper Memory leak issue
2 participants