Repository navigation
fix(relay): revive a dead relay broker without user interaction - #12432
Conversation
Broker deaths that end with closeNow() — an auth refresh failing past token expiry (laptop sleep) or a transient context read at open — left no retry timer, so Relay stayed offline until the user clicked Retry or auth state changed. Adds a dead-man's switch: - RelayAuthCoordinator.ensureLive(): reconciles only when there is no live broker, no scheduled retry, and no open in flight - DesktopRelayService arms a 5-minute liveness interval and exposes ensureLive() for wake signals - powerMonitor 'resume' triggers ensureLive (sleep is the common cause)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe relay coordinator now exposes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
The 5-minute liveness tick from #12432 survived fenceAndCloseNow(), so a tick landing between the pre-sign-out fence and the profile wipe could briefly resurrect a broker (benign but soft — the entitlement check bails afterward). The fence now clears the interval; the next auth mutation re-arms it via refreshDemand, and the safety net otherwise behaves identically. Found in release review of the #12432 cherry-pick. Co-authored-by: OrcaWin <[email protected]>
Broker deaths that end with closeNow() — an auth refresh failing past token expiry (laptop sleep) or a transient context read at open — left no retry timer, so Relay stayed offline until the user clicked Retry or auth state changed. Adds a dead-man's switch: - RelayAuthCoordinator.ensureLive(): reconciles only when there is no live broker, no scheduled retry, and no open in flight - DesktopRelayService arms a 5-minute liveness interval and exposes ensureLive() for wake signals - powerMonitor 'resume' triggers ensureLive (sleep is the common cause) Co-authored-by: OrcaWin <[email protected]>
The 5-minute liveness tick from #12432 survived fenceAndCloseNow(), so a tick landing between the pre-sign-out fence and the profile wipe could briefly resurrect a broker (benign but soft — the entitlement check bails afterward). The fence now clears the interval; the next auth mutation re-arms it via refreshDemand, and the safety net otherwise behaves identically. Found in release review of the #12432 cherry-pick. Co-authored-by: OrcaWin <[email protected]>
…lyai#12432) Broker deaths that end with closeNow() — an auth refresh failing past token expiry (laptop sleep) or a transient context read at open — left no retry timer, so Relay stayed offline until the user clicked Retry or auth state changed. Adds a dead-man's switch: - RelayAuthCoordinator.ensureLive(): reconciles only when there is no live broker, no scheduled retry, and no open in flight - DesktopRelayService arms a 5-minute liveness interval and exposes ensureLive() for wake signals - powerMonitor 'resume' triggers ensureLive (sleep is the common cause) Co-authored-by: OrcaWin <[email protected]>
…yai#12482) The 5-minute liveness tick from stablyai#12432 survived fenceAndCloseNow(), so a tick landing between the pre-sign-out fence and the profile wipe could briefly resurrect a broker (benign but soft — the entitlement check bails afterward). The fence now clears the interval; the next auth mutation re-arms it via refreshDemand, and the safety net otherwise behaves identically. Found in release review of the stablyai#12432 cherry-pick. Co-authored-by: OrcaWin <[email protected]>
Follow-up from the relay incident handoff: "the desktop still gives up permanently after its launch burst (no periodic broker retry — needs an orca-repo fix)".
The gap
The coordinator retries open failures (transient HTTP/network, honoring Retry-After, 5min-capped jitter — #10147/#12076) and the origin pool retries drain/close recovery indefinitely. But two death paths end with
broker.closeNow()and no timer:refreshAuthorization()failing pastexpiry + 60s— the normal outcome of a laptop sleeping through relay-token expiry (relay-session-broker.ts).refreshAccessToken()returning null on a transient auth-context read.After that, only an external event (auth mutation, demand change, user Retry) ever calls
reconcile()— a desktop that slept overnight staysofflineuntil poked. This is the D7 follow-up from the incident review.The fix
RelayAuthCoordinator.ensureLive(): a guarded reconcile that no-ops when there is a live broker (isLive?.() ?? true), a scheduled retry timer, or an open in flight — so it can never disturb the existing retry machinery or add Director load while recovery is already running. It reconciles withresetRetry=false, preserving backoff escalation.DesktopRelayService: 5-minutesetIntervalliveness tick (cleared onstop()), plus a publicensureLive().index.ts:powerMonitor.on('resume', …)— sleep is the common trigger, so resume gets an immediate check instead of waiting up to 5 minutes.Load: when registered, the tick costs one
isLive()call (no I/O). When dead, one reconcile per 5 minutes worst case, still gated by the coordinator's own Retry-After handling — negligible next to the current retry cohort behavior.Tests
ensureLivereopens a broker that died with no pending retry (closes the dead broker, activates the replacement)ensureLiveno-ops against: a scheduled Retry-After timer, an open in flight, and a live broker