Repository navigation
fix(client): stop the local-credential observer when the runtime recycles to standalone - #8710
Conversation
…cles to standalone recycleStandalone stopped the reporter, the route-intent watch and tick, the link supervisor and the listener, but not the local-credential observer, which only stopServing stopped. That observer is meant to live exactly while the process serves; after a recycle it kept its fs.watch handles on directories under the config home until the process exited, including across the replacement handoff. On Windows a watched directory cannot be deleted, so the route-intent runtime-stop fixture's sandbox removal retried for its whole 14.85s budget and the preload's afterAll timed out (windows 5/14 in dev batches 43451726885 and 43483630535). On macOS the observer refused the /var symlink parent and on Linux inotify does not block deletion, which hid the leak. The observer is now module state like the other active runtime parts, and the recycle stops it before the replacement handoff. The fixture asserts that.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8e334e017
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const replacementEnv = port && !serviceSupervised | ||
| ? withSiblingMarker(standaloneRecycleEnv(process.env, disconnectedTokenFingerprint), issueSiblingHandoff) | ||
| : null; | ||
| activeCredentialObservation?.stop(); activeCredentialObservation = null; |
There was a problem hiding this comment.
Update the required architecture documentation with the lifecycle fix
This changes the client runtime's credential-observer ownership and recycle teardown, but the commit updates only the runtime and its test. structure/INDEX.md maps src/client/ to structure/runtime.md, structure/fallback-policy.md, and structure/clients/claude-desktop.md; the source instructions explicitly require every document listed for a changed area to be updated in the same change. Update those owned documents to reflect or cross-reference the observer lifecycle and its regression coverage so this change satisfies the repository's architecture-sync requirement.
AGENTS.md reference: src/AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
|
Maintainer judgment: integrating into Exact head b8e334e:
Client lifecycle fix with no change to authentication, credentials or workflows; no outstanding maintainer change requests. |
Summary
windows 5/14 failed in two dev batches in a row (43451726885, 43483630535) on
tests/clients/route-intent-runtime-stop.test.ts"runtime recycle cancels its watch and tick before replacement handoff". The fixture's own case passed in under a second; then an unnamed hook "timed out after 5000ms" and the child reported 14,902 ms and 14,904 ms. The attribution sweep reproduced it alone.That hook is
tests/preload.ts'safterAll, whose sandbox removal (removeTestTempTree) retries synchronously on EPERM/EBUSY: 61 attempts with 14,850 ms of waits, which is the measured duration. Something in the process still held a directory in the sandbox open.It was the local-credential observer.
startClientRuntimestarts it when it publishes (observeLocalCredentials), and its comment says it "lives exactly while this process serves".stopServingstops it, butrecycleStandalonedid not: it stopped the reporter, the route-intent watch and tick, the link supervisor and the listener, and left the observer and itsfs.watchhandles on directories under the config home running through the replacement handoff and until the process exited. A watched directory cannot be deleted on Windows. On macOS the observer refused the sandbox (the/varsymlink parent failsassertParents), and on Linux inotify does not block deletion, so only Windows showed it.The observer is now module state like the other active runtime parts (
activeCredentialObservation), and the recycle stops it together with them, before the replacement handoff. The fixture records the stop and asserts it happened exactly once, beforereplacement.Verification
TMPDIRso the observer actually starts: a probe aroundstartLocalCredentialObservationreported{"started":1,"stopped":0}afterrecycleStandalone.origin/dev(expect(...).toHaveLength(1), received 0) and passes with the fix.bun testover the 12 files that exercisesrc/client/runtime.ts(client runtime, restart, link runtime, desktop-supervised restart, disconnect runtime, client start fence and owner e2e, link apply restart, service signal exit, route-intent runtime stop): 188 pass / 0 fail.bun run typecheck: exit 0.Checklist
Summary by CodeRabbit