Repository navigation
feat: opt in to a Reopen after a failed open - #441
Merged
Merged
Conversation
Merged
6 of 10 tasks
…, and what that costs
…cket apart from the outer one
diegolmello
approved these changes
Nov 26, 2026
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.
Proposed changes
Adds an opt-in socket option,
reopenAfterFailedOpen. With it on, aconnect()that fails schedules a Reopen, the same as a lost connection does, instead of leaving the Socket Idle. It defaults tofalse, so nothing changes for clients that don't pass it.Why: the app's main client calls
connect()on a cold start. Without network, that first open fails, nothing schedules a Reopen, and the app stays on "Connecting..." until the next foreground. The app's probe clients (getWebsocketInfo,logoutFromServer) rely on a failed open giving one answer and going Idle, so this can't be the default.How it works:
Connection.open()starts its ordinary attempt with recovery intent when the option is on:start(false, recovery || reopenAfterFailedOpen). A failure, including a deadline that runs out, then creates one Scheduled Reopen, and each failed Reopen schedules the next, as after a dropped connection.reopenNow()cancels the Scheduled Reopen, or supersedes the in-flight attempt, and starts its own. A forced retry would makereopenNow()join an attempt that may have started before the network came back.close()still cancels everything.connect()still rejects with the first failure.ADR-0014 is rewritten in place: the two bullets on one-shot
open()now name the option. CONTEXT.md's Reopen entry covers a failed open.Issue(s)
https://rocketchat.atlassian.net/browse/SUP-1128
App PR: RocketChat/Rocket.Chat.ReactNative#7833
How to test or reproduce
npm test,npm run typecheck,npm run lint.lib/drivers/__tests__/socket.open.spec.ts, "an ordinary open with reopenAfterFailedOpen": all four tests fail with the option ignored inConnection.open().Types of changes
🤖 Generated with Claude Code