Skip to content

fix(relay): make fenceAndCloseNow stop the liveness safety net - #12482

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix/fence-clears-liveness-tick
Aug 4, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
fix/fence-clears-liveness-tick

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #12432, found during release review of its cherry-pick onto v1.4.168-rc.3 (credit: the release agent).

fenceAndCloseNow() didn't clear the 5-minute liveness interval — only stop() did — so after a sign-out fence the safety net kept ticking. Mostly benign (each tick's reconcile re-reads the auth context and bails on !context || !relayEntitled), but a tick landing in the window between the pre-sign-out fence and the profile wipe could briefly resurrect a broker, making the fence soft instead of hard.

Fix: the fence clears the interval; refreshDemand() (start, auth mutation, demand change) re-arms it, so a subsequent sign-in restores the safety net. stop() behavior unchanged.

Test: red-before/green-after lifecycle test — tick fires while started, goes silent after fence (30 simulated minutes), resumes after authMutated(), silent after stop(). Verified failing against the pre-fix service.

Not needed for the v1.4.168 promotion — this hardens main; the RC cherry-pick of #12432 stands as reviewed.

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.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The desktop relay service now initializes liveness monitoring from refreshDemand() instead of start(). fenceAndCloseNow() clears the active liveness timer before fencing and closing the coordinator. Tests use Vitest fake timers to verify activation, cancellation, reactivation after authMutated(), and inactivity after stop(). Timer cleanup runs after each test.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fix and test, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all required template sections, state “No visual change,” record test checklist results, and include AI review, security audit, and platform compatibility details.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: stopping the liveness safety net during fencing.
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.
✨ 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/desktop-relay-service.test.ts (1)

80-83: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the pending-demand expiry path.

Line 80 returns null, so this test cannot detect a demandExpiryTimer firing after fenceAndCloseNow(). Add a case with a near-future expiry and assert that ensureLive() remains unchanged until authMutated().


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ddc2e9e-ff52-4e45-9497-eec21a616f06

📥 Commits

Reviewing files that changed from the base of the PR and between 8f29f58 and 86b6453.

📒 Files selected for processing (2)
  • src/main/runtime/relay/desktop-relay-service.test.ts
  • src/main/runtime/relay/desktop-relay-service.ts

@Jinwoo-H
Jinwoo-H merged commit e9cf106 into main Aug 4, 2026
43 checks passed
@Jinwoo-H
Jinwoo-H deleted the fix/fence-clears-liveness-tick branch August 4, 2026 08:38
AmethystLiang pushed a commit that referenced this pull request Aug 4, 2026
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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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]>
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