Skip to content

fix(wsl): forget an interrupted wake's token once its fence is settled - #35759

Merged
nwparker merged 1 commit into
mainfrom
nwparker/wsl-wake-stale-token
Oct 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/wsl-wake-stale-token

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28

ELI5

When a WSL host start is cut off mid-way, Orca keeps a note so it can later clean up the lock that start left behind. If the server came back up some other way, Orca never cleared that note. While the note existed, the faster one-lock start from #35708 stayed off until the app restarted. Now the note is cleared as soon as Orca can see the lock is gone or belongs to someone else.

What Changed

  • Before: wakeAfterPrior returned "serving" (or "unverifiable") before reaching the branch that clears an interrupted wake's token. A stale token therefore stayed in interruptedWakes. perf(wsl): take one activation fence on a same-version connect #35708's wakeExpectedOrcadUnderOneFence answers "fenced" whenever a token is on record, so every later same-version connect took the slower two-fence path.

  • After: before that early return, forgetSettledInterruptedWake runs. It does nothing unless a token is on record. If one is, it deletes it only when:

    • the activation fence no longer exists, or
    • the fence's owner file names a different token.

    An owner file not yet written, or a probe that gets no answer, keeps the token. That is the same caution releaseOwnInterruptedWakeFence uses.

Why

This is review feedback on #35708 from d1c-review-high. The token exists only so the full wake can prove a dropped fence is its own. Once the fence is gone or another run's, the token proves nothing, and keeping it only disables the one-fence path. The extra reads run only when a token is on record, which is rare.

Flag-off: the token only gates the WSL one-fence wake, which runs only with ORCA_INTERNAL_WSL_HOSTS set. SSH wakes see no change except the same token cleanup on the rare interrupted-wake path.
User-risk: low. A token is cleared only on positive evidence that its fence is gone or someone else's.

Linked Issue

N/A (follow-up to #35708).

Visual Proof

N/A: no UI.

Testing

orcad-managed-wake-one-fence.test.ts:

  • A one-fence wake drops at launch, the slot comes back, and a full wake finds it serving.
    • With the fence gone, the token is cleared, and the next one-fence connect answers "serving".
    • With the fence owned by another run, the same.
    • With the fence still its own, the token stays, and the one-fence connect still answers "fenced".
  • The test fails without the fix.

orcad-managed-wake.test.ts (16) and wsl-orcad-one-fence-deploy.test.ts pass. pnpm tc, pnpm run typecheck:ci, the changed-code quality gate, anti-slop oxlint and oxlint all pass.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No wire change. SSH keeps the same wake behaviour.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

A wake that finds the slot serving returned before the fence branch that
clears an interrupted wake's token, so a stale token kept WSL's one-fence
wake answering 'fenced' until restart. Before that early return, forget
the token when its fence is gone or names another owner.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fcdcd27a-94b6-4d88-b8e3-72a31b313ce4
Commits

Reviewing files that changed from the base of the PR and between f245dc7 and 64032d5.

Files selected for processing: 2
  • src/main/managed-server/lifecycle/orcad-managed-wake-one-fence.test.ts
  • src/main/managed-server/lifecycle/orcad-managed-wake.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The change affects interrupted wake recovery and the same-version WSL connect path.

The production change appears safe to merge; the test cleanup issue is non-blocking.

Findings

  1. P2 Tests depend on their order ▶

Summary

Clears stale interrupted-wake tokens before a full wake returns serving or unverifiable.

  • A serving full wake clears an interrupted token when its fence has settled.

Reviews (1) · Last reviewed commit: "fix(wsl): forget an interrupted wake's t..." · Reviewed by Greptile

Comment on lines +193 to +195
await dropOneFenceWake()
expect(await wakeStoppedManagedOrcad(slot)).toEqual({ outcome: 'serving' })
expect(await wakeExpectedOrcadUnderOneFence(slot, OLD)).toEqual({ outcome: 'fenced' })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Tests depend on their order

This test leaves an interrupted token behind for the shared slot. beforeEach clears mocks but not interruptedWakes, so moving this test before another one-fence test makes that test return fenced instead of doing its work. After checking that the token stays, stop the fake server and complete a full wake to clear it.

@nwparker
nwparker merged commit 084c765 into main Oct 29, 2026
64 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.

1 participant