Repository navigation
fix(mobile): abandon pairing journals that can no longer reconcile - #12773
Conversation
A pairing attempt interrupted after it recorded winner/authorizationMode leaves a journal behind. `saveMobileRelayPairingJournal` then refuses every later attempt with "mobile relay pairing recovery pending", and recovery could only ever return 'deferred' on failure — it never cleared the journal. Once the invite expired, no credential remained that could establish what happened, so the block was permanent: relay pairing stayed dead until app data was wiped. Hit for real during the 2026-08-05 relay lock-timeout incident, where pairings died mid-flight and recovery then could not reach the relay to reconcile them. Recovery now abandons a journal whose invite has expired, since nothing can reconcile it after that point and re-pairing mints a fresh device while any uncommitted server-side install expires on its own. A journal whose invite is still live keeps deferring, so a transient outage never discards a still-reconcilable attempt.
…rding Abandoning exactly at invite expiry let a momentary relay outage discard a journal whose resume credential would have reconciled it on the next launch. Wait one further invite lifetime so only journals that have been unreconcilable well past any short outage are cleared.
📝 WalkthroughWalkthroughMobile relay pairing recovery now returns 🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
mobile/src/transport/mobile-relay-pairing-recovery.test.ts (1)
223-237: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winCover journal-clear failure.
The expired test covers only a successful
clearJournalcall. The new branch intentionally suppresses clear failures at Line 146. Add a case whereclearJournalrejects and assert the intended'abandoned'result. This locks the best-effort error contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1e875659-41e6-4d0c-b9fd-ca9404064097
📒 Files selected for processing (2)
mobile/src/transport/mobile-relay-pairing-recovery.test.tsmobile/src/transport/mobile-relay-pairing-recovery.ts
publishCommitted runs inside the credential loop's catch, so a failed local write — keychain or storage rejecting writeCredentialBundle or saveHost after the relay authoritatively reported the install committed — fell through to the stale-expiry branch and cleared the journal. That destroys the one record left to retry the write from, stranding a credential the desktop already holds. Track the authoritative commit separately from local persistence and never abandon once it has been observed; that journal stays until the write succeeds. Reported by CodeRabbit on #12773.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/transport/mobile-relay-pairing-recovery.test.ts (1)
258-270: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert that the failing credential write is reached.
publishCommittedchecksendpoints.relaybefore it callswriteCredentialBundle. This test only checks the result andclearJournal. A malformed endpoint fixture could therefore pass for the wrong reason.Add a call assertion for
writeCredentialBundle.Proposed assertion
await expect(recoverMobileRelayPairing(deps)).resolves.toBe('deferred') + expect(deps.writeCredentialBundle).toHaveBeenCalled() expect(deps.clearJournal).not.toHaveBeenCalled()
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 306528bb-ad59-46db-af03-c8ff079c6a16
📒 Files selected for processing (2)
mobile/src/transport/mobile-relay-pairing-recovery.test.tsmobile/src/transport/mobile-relay-pairing-recovery.ts
Relay pairing can wedge permanently with
pairing failed: mobile relay pairing recovering pending, with no way out short of wiping app data. Hit for real today.The trap
saveMobileRelayPairingJournalrefuses to start a new pairing while an unresolved journal exists that already recordedwinner/authorizationMode— correct, since overwriting it could orphan a device registration.The escape hatch is
recoverMobileRelayPairing()at app startup, which asks the relay what became of the attempt. But every failure path inrunRecoveryfell through toreturn 'deferred', which keeps the journal. AndrecoveryCredentialsonly offers the invite whileinviteExpiresAt > now. So once the invite expires:That is a permanent block: relay pairing stays dead across restarts and reinstalls of the JS bundle, forever, because restarting reruns the identical logic. Quitting and reopening the app cannot help.
How it triggered
During today's relay lock-timeout incident (orca-cloud#231), pairings died mid-flight after recording winner/authorization. Recovery then could not reach the relay to reconcile them, so it deferred — and by the time the relay was healthy the invites had expired, leaving journals that could never be cleared.
Fix
Recovery now abandons a journal whose invite has expired, because after that point nothing can establish what happened. Re-pairing mints a fresh device, and any uncommitted server-side install expires on its own — so the cost of abandoning is one re-pair, versus permanently broken pairing.
A journal whose invite is still live keeps deferring, so a transient outage never discards a still-reconcilable attempt. That distinction is the one that matters, and it is covered by both tests.
Tests
'abandoned',clearJournalcalled'deferred',clearJournalnot calledRed before green by construction:
'abandoned'did not previously exist as an outcome. Recovery suite 5/5,tscand oxlint clean.Follow-up
The user-facing error is still a dead end — it names an internal concept and offers no action. Worth surfacing as "finishing a previous pairing… / start over" in the pairing UI, tracked with the other mobile relay UX work rather than widened here.