feat(graphql): backoff for dropped connection after ACK#864
Closed
stdevi wants to merge 4 commits into
Closed
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merged
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.
Add exponential backoff before reconnecting when an already-established GraphQL WebSocket connection drops, so a connection that keeps dropping right after
connection_ackdoesn't turn into a tight reconnect loop.Previously
handleConnectionDrop()(pong timeout, failed send, or resubscription failure) reconnected immediately viaopenSocket(). Each reconnect mints a fresh temporary API key, so a server that drops the socket right after ACK produced a fast key-minting loop. Theonclosehandler already backed off for connections that never established; this brings the post-ACK drop path in line.So now we:
handleConnectionDrop()usingcalculateRandomizedExponentialBackoffTime(connectionAttemptsCount)before reconnecting, reusing the same counter asonclose(reset to 0 onGQL_PONG), so a healthy connection that drops starts from the minimum.tearDownSocket()) before the backoff sleep, so itsonclosecan't fire a second, parallel reconnect during the delay. The handlers are nulled beforeclose(), so the asynchronous close event has nothing left to trigger.DISCONNECTEDemit up front, so the dashboard's connection-loss status is unaffected.tearDownSocket()helper used by bothcreateSocketConnection()andhandleConnectionDrop().How to test
yarn test(new tests ingraphql-reconnect-resilience.spec.ts):onclosecan't reconnectBumps
qminder-apito 17.0.5.