Skip to content

fix: recover Relay broker startup after transient failures - #10147

Merged
Jinwoo-H merged 6 commits into
mainfrom
OrcaWin/relay-desktop-transient-recovery
Jul 23, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
OrcaWin/relay-desktop-transient-recovery

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • retry transient cloud-session refresh, Relay token exchange, assignment, and initial control-open failures with capped full-jitter backoff
  • keep brief-failure recovery fast, then grow sustained-outage jitter to a five-minute ceiling to protect auth/director capacity
  • re-read session, identity, entitlement, and Relay demand before every retry
  • cancel stale retry ownership immediately on sign-out/fencing, profile or organization changes, stop, or zero demand
  • leave permanent HTTP authorization/configuration failures event-driven rather than polling them

Why

A transient startup failure currently leaves an entitled, demanded desktop in offline until the process restarts or another auth event occurs. This restores the control automatically without changing pairing credentials or existing direct transport behavior.

The longer sustained-outage cap prevents a large desktop population from retrying every 30 seconds on average after the service has already been unavailable for several minutes. The initial 1/2/4/8-second exponential sequence is unchanged.

Validation

  • internal review completed in two rounds; the first found and fixed the pre-identity cloud-session refresh gap, and the second found no remaining issues
  • 54 Relay tests pass on supported Node 24.18, including timer-time session/demand/entitlement rechecks, immediate fencing, and deterministic five-minute cap coverage
  • full pnpm typecheck passes on Node 24.18
  • focused oxlint/React Doctor/format and git diff --check pass
  • branch synced with current main
  • GitHub run 30044441630 passed the full lint, typecheck, Git compatibility, test, unpacked build, and packaged CLI workflow on reviewed head 5dfd5d29a9

This PR is intentionally not authorized for merge yet; it is separate from the production cloud hotfix.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds relay connection error classification and coordinator retry handling with exponential backoff and jitter. Reconciliation now tracks, cancels, and resets retry state, validates identity continuity, and fences pending retries during shutdown. Tests cover transient recovery, permanent authorization failures, demand cancellation, and identity changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers summary, rationale, and validation, but it omits required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, including No visual change screenshots, AI review details, a security audit, and any platform-specific notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: recovering Relay broker startup after transient failures.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/runtime/relay/relay-auth-coordinator.ts (1)

181-189: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Caught connection error is never logged.

The error is swallowed here — neither the retry nor the "give up" (permanent-failure) path records what actually failed. For persistent transient failures or unexpected non-RelayHttpError exceptions (see companion note on relay-http-client.ts), operators only ever see repeated offline status callbacks with no way to diagnose the cause in production.

🔍 Suggested logging addition
     } catch (error) {
       if (this.isEpochCurrent(epoch)) {
         this.options.onStatus('offline')
+        console.error('[relay-auth-coordinator] reconcile failed', error)
         if (retryIdentityKey && shouldRetryRelayConnectionError(error)) {
           this.scheduleRetry(epoch, retryIdentityKey)
         }
       }
     }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 86ad0e1c-8491-4e4a-abf4-f65e93f03c1e

📥 Commits

Reviewing files that changed from the base of the PR and between 7ab6014 and 2d56194.

📒 Files selected for processing (3)
  • src/main/runtime/relay/relay-auth-coordinator-recovery.test.ts
  • src/main/runtime/relay/relay-auth-coordinator.ts
  • src/main/runtime/relay/relay-http-client.ts

@AmethystLiang

Copy link
Copy Markdown
Contributor

looking into it

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

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.

3 participants