Repository navigation
fix(lib): reconnect when the first WebSocket attempt is refused - #2216
Merged
Merged
Conversation
Node's WebSocket (undici) fires only 'error' on a refused connection, never 'close'. The client scheduled its retry and rejected openPromise on 'close' alone, so a Store whose first attempt came before the server listened stayed offline for good. This is the dead socket in develop runs 5208 and 5211, where upload-roundtrip logged '[WS] Connection failed' and then waited out its timeout. Teardown and retry now run once per socket from 'close', and from 'error' when the socket never opened.
Member
Author
|
Complexity review after merge (+130/-49 in The per-socket Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: in Node, a Store whose first WebSocket attempt was refused (server not listening yet, or a busy runner) stayed offline forever. It logged "[WS] Connection failed" once and never tried again. This is the dead socket behind the upload-roundtrip reds in develop runs 5208 and 5211, which stop the lib integration stage and hide every e2e result.
After: the client retries on the normal backoff and connects as soon as the server answers.
Node's WebSocket (undici) fires only
erroron a refused connection, neverclose. The client scheduled its retry, and rejectedopenPromise, onclosealone.How: teardown and retry move into one
end()per socket, run at most once, called fromcloseand fromerrorwhen the socket never opened.openPromiserejects from there too. Browsers, which do firecloseaftererror, behave as before.Test:
tests/ws-reconnect.integration.test.tspoints a Store at a port that refuses, then puts the real server behind that port. It is red without the fix ("expected false to be true") and green with it. Lib unit tests (1550) and all lib integration tests pass locally, including upload-roundtrip.Generated by Claude Code