Skip to content

fix(websocket): queue close events after CONNECTING close#5088

Closed
tejasp2022 wants to merge 2 commits intonodejs:mainfrom
tejasp2022:dev/tejas/fix-ws-close-connecting-async
Closed

fix(websocket): queue close events after CONNECTING close#5088
tejasp2022 wants to merge 2 commits intonodejs:mainfrom
tejasp2022:dev/tejas/fix-ws-close-connecting-async

Conversation

@tejasp2022
Copy link
Copy Markdown

Summary

  • add a regression test for calling WebSocket.close() while the socket is still CONNECTING
  • queue the CONNECTING failure close-path for WebSocket so error and close fire after close() returns
  • keep WebSocketStream on the old synchronous path so its pre-open abort behavior stays unchanged

Fixes #4741

Test plan

  • node --test test/websocket/issue-4741.js test/websocket/issue-3546.js test/websocket/issue-4273.js test/websocket/issue-3697-2399493917.js test/websocket/stream/abort-before-open.js
  • npm run test:websocket on Node 22.19.0

Notes

  • npm run test:websocket still reports failures in test/websocket/opening-handshake.js, test/websocket/issue-4989.js, and test/websocket/diagnostics-channel-handshake-response-h2.js.
  • I reproduced those same three H2 websocket failures on an untouched main clone under Node 22.19.0, so they do not appear to be introduced by this patch.

Copy link
Copy Markdown
Author

@tejasp2022 tejasp2022 left a comment

Choose a reason for hiding this comment

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

fix(websocket): queue close events after CONNECTING close

@tejasp2022 tejasp2022 closed this Apr 24, 2026
@tejasp2022 tejasp2022 deleted the dev/tejas/fix-ws-close-connecting-async branch April 24, 2026 17:09
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.

WebSocket events fire synchronously during close() instead of asynchronously

1 participant