Skip to content

Conversation

@emmachase
Copy link
Contributor

@emmachase emmachase commented Apr 17, 2025

Properly handle websocket disconnection when called during the CONNECTING state. Previously, sockets in this state weren't terminated, leaving them dangling in the CONNECTING state. If the disconnect was part of a connection retry, new sockets would attempt to connect while the original socket remained still trying to connect.

When the original connection eventually resolved, this created a thundering herd. And while those dropped connections wouldn't emit any events, it still imposes an undue burden on the target server as they will still receive messages (until the server or client decides to disconnect for some reason).

@changeset-bot
Copy link

changeset-bot bot commented Apr 17, 2025

🦋 Changeset detected

Latest commit: b098ba4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
partysocket Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@emmachase emmachase changed the title Close if disconnect is called during CONNECTING state Close websocket if disconnect is called during CONNECTING state Apr 17, 2025
emmachase added 2 commits May 8, 2025 20:08
Properly handle websocket disconnection when called during the CONNECTING state. Previously, sockets in this state weren't terminated, leaving them dangling in the CONNECTING state. If the disconnect was part of a connection retry, new sockets would attempt to connect while the original socket remained still trying to connect.

When the original connection eventually resolved, this created a thundering herd. And while those dropped connections wouldn't emit any events, it still imposed an undue burden on the target server.
Copy link
Collaborator

@threepointone threepointone 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 good, thank you!

@threepointone threepointone merged commit e5b2ea1 into cloudflare:main May 8, 2025
1 check passed
@threepointone threepointone mentioned this pull request May 8, 2025
@emmachase emmachase deleted the patch-1 branch May 8, 2025 16:04
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.

2 participants