feat(graphql): block retry if connection not established#854
Open
stdevi wants to merge 1 commit into
Open
Conversation
raluik
approved these changes
Jun 12, 2026
| // Each cycle: connect, never ACK, close before the connection is established. | ||
| for (let i = 0; i < MAX_FAILED_HANDSHAKES; i++) { | ||
| await fixture.waitForConnection(); | ||
| await fixture.getNextMessage(); // consume connection_init |
Contributor
There was a problem hiding this comment.
polish: we have consumeInitMessage. Then there's no need for the comment.
| await fixture.closeWithCode(1001); | ||
| fixture.openServer(); | ||
| } | ||
| await new Promise((resolve) => setTimeout(resolve, 20)); |
Contributor
There was a problem hiding this comment.
polish: seems to be unnecessary.
raluik
reviewed
Jun 12, 2026
| const timer = calculateRandomizedExponentialBackoffTime( | ||
| this.connectionAttemptsCount, | ||
| if (closedBeforeEstablished) { | ||
| this.consecutiveFailedHandshakes++; |
Contributor
There was a problem hiding this comment.
suggestion(non-blocking): could we possibly gain sth by logging this?
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.
Back off the GraphQL WebSocket reconnect loop when the socket repeatedly fails to establish, so the SDK stops minting a new temporary API key on every retry.
When a client's firewall blocks
wss://(but not HTTPS), every reconnect attempt fetched a fresh temporary API key over HTTPS and then failed the WebSocket handshake forever, ~1 key/minute per device.So now we:
consecutiveFailedHandshakes).MAX_FAILED_HANDSHAKES(5), the existing reconnect loop backs off to a flatBLOCKED_RETRY_INTERVAL_MS(5 min) instead of the fast exponential backoff.GQL_CONNECTION_ACK, so it recovers automatically once the connection succeeds.How to test
Set up sign-in-wrapper with javascript-api and ipad-sig-in on master first.
Navigate to name.local and set up iPad.
Go to uBlock Origin settings:

Go to
My filtersand disable websockets:*$websocketYou will see how iPad created keys.
Then switch to this PR for javascript-api. The backoff will be applied.