Skip to content

fix(sio): ignore a duplicate CONNECT packet while the namespace connection is pending - #5643

Open
cestercian wants to merge 1 commit into
socketio:mainfrom
cestercian:fix/duplicate-connect-packet
Open

cestercian wants to merge 1 commit into
socketio:mainfrom
cestercian:fix/duplicate-connect-packet

Conversation

@cestercian

Copy link
Copy Markdown

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

Two CONNECT packets for the same client and namespace can both get through. client.nsps is only filled in after the socket is created and the middleware runs, so the second packet still looks like a new connection. You get two Sockets, connection fires twice, and disconnecting one later removes the namespace entry for both.

New behavior

A duplicate CONNECT is ignored while that namespace connection is still pending. The mark is cleared when the handshake succeeds, when a dynamic namespace is denied, when middleware fails, and when the client closes before next(). A later CONNECT after a CONNECT_ERROR still works.

Other information (e.g. related issues)

Fixes #5642. Same race as the client change in #5623.

The new regression test failed on main with expected 2 to sort of equal 1, then passed with the fix. npm run format:check, npm run compile, and npm run test:unit in packages/socket.io are green (221 passing).

@cestercian

Copy link
Copy Markdown
Author

Hey, gentle bump on this one when someone has a moment. Happy to add more tests or rework it if needed.

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.

Duplicate CONNECT packets create two Sockets and fire connection twice

1 participant