Skip to content

feat: opt in to a Reopen after a failed open - #441

Merged
OtavioStasiak merged 4 commits into
mobilefrom
feat/reopen-after-failed-open
Nov 26, 2026
Merged

OtavioStasiak merged 4 commits into
mobilefrom
feat/reopen-after-failed-open

Conversation

@OtavioStasiak

Copy link
Copy Markdown
Contributor

Proposed changes

Adds an opt-in socket option, reopenAfterFailedOpen. With it on, a connect() that fails schedules a Reopen, the same as a lost connection does, instead of leaving the Socket Idle. It defaults to false, 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.
  • The attempt is never forced. A later reopenNow() cancels the Scheduled Reopen, or supersedes the in-flight attempt, and starts its own. A forced retry would make reopenNow() 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 in Connection.open().
  • Without the option, "rejects the attempt when the transport reports an error" still pins the Socket going Idle.

Types of changes

  • New feature (non-breaking change which adds functionality)

🤖 Generated with Claude Code

@OtavioStasiak
OtavioStasiak merged commit e90a19f into mobile Nov 26, 2026
4 checks passed
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.

2 participants