Repository navigation
fix(link): keep the orphan checks working when a stale pidfile cannot be removed, and check a gained link's pidfile even without a flag - #8621
Merged
lidge-jun merged 2 commits intoNov 13, 2026
Conversation
…ink's pidfile even unflagged, and cap the pidfile read A pidfile removal that failed (a read-only directory, a sharing lock) threw out of the supervisor tick, skipped every other link's work that tick, and left the link flagged with nothing to lift it. A stale pidfile whose process is gone is harmless, so the failure is now warned and the tick goes on. A link that gains routes with no running child now settles from its pidfile even without a flag, since removing a link drops its flag. The strict pidfile read is capped at 64 KiB. Docs: signalling a proven process can also happen on a later tick, and a link whose pidfile was deleted starts within a second or when its retry is due. Refs #8609
The cap was optional. One read call can return a short read, and the capped reader also feeds the one-route startup path, where an oversized file would read as no pidfile. The strict reader is back to reading the whole file, as on dev. Refs #8609
Contributor
|
Caution Review failedThe pull request is closed.
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. |
Contributor
|
✅ Deterministic PR hygiene checks passed. |
lidge-jun
marked this pull request as ready for review
November 13, 2026 02:23
lidge-jun
deleted the
fix/link-orphan-pidfile-removal-and-gained-routes
branch
November 13, 2026 02:23
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Last follow-up to #8616 (issue #8609), from the final review of that PR. A Remote Link with several routes must never start a route candidate while an earlier ssh tunnel of it may still run. The Home supervisor flags such links
orphan-unverified, watches the process named in the link's pidfile, and since #8616 reads an unreadable pidfile again on every tick.A pidfile that could not be removed stopped the tick. Once a watched process is gone, the supervisor removes its pidfile. That happens at two places: when a watch ends, and in the orphan reaper's gone-process branch, which the per-tick re-read, startup, gained routes and the reload of an added link all reach. A removal that failed with anything other than ENOENT (a read-only directory, an immutable flag, a Windows sharing lock) threw out of the tick, or out of
start()orreload(). The rest of that tick's work was skipped for every link, and the link was left flagged with no watch and no re-read entry, so it stayed blocked until a restart. Both sites now calldropStalePidfile, which logs[link] stale pidfile could not be removed link=<id>and goes on. A pidfile whose process is gone is harmless: the next start finds the process gone again.A link that gained routes without a flag skipped its pidfile. When a one-route link gains routes, the supervisor checked the pidfile only if the link was flagged. Since #8616 removing a link clears its flag. So a one-route link that was removed, added again, and failed to spawn (ssh missing, say) gained routes without any check, and its rounds could start while an earlier Home's ssh still held the port. The cost was refused forwards and 60 s rests until that ssh exited. Every gained link with no running child and no watch now settles from its pidfile, flagged or not. A link without a pidfile is unaffected (ENOENT), and a running child, including one adopted when the link gains routes, is never checked.
Docs.
structure/remote-link.mdnow says that a process with a proven identity can be signalled at startup or on a later tick, once an unreadable pidfile becomes readable. It also describes the gained-routes check and the removal warning. The Remote Link guide's stale-tunnel bullet now says a link whose pidfile was deleted starts within a second "or when its retry is due", because the round starts at once only for an idle link. The guide's seven translated copies (fr, ja, ko, ru, tr, zh-cn, zh-tw) do not have this section yet, so only the English guide changes.What keeps this inert. Only links with several routes are affected, and only when a pidfile removal fails or a link without a flag or running child gains routes. One-route links, the pidfile reader, configuration and defaults are unchanged.
Verification
Tests written first in
tests/clients/link-route-supervisor.test.ts. The harness gained an option that makes pidfile removal throw EACCES. Withsrc/link/supervisor.tsput back todev(f7c2131), the final test file gives 62 pass and 3 fail; the three failures are the new tests below that are marked as failing ondev.a stale pidfile that cannot be removed once its watched process is gone does not stop the tick: ondev, EACCES escapes the tick at the end of the watch.a re-read pidfile naming a gone process that cannot be removed lifts the block and starts the round: ondev, EACCES escapes the tick from the orphan reaper.a link that gains routes without a flag or a running child still has its pidfile checked(flagged at start, removed, re-added with ssh missing, given routes): ondevthe link is not flagged.a pidfile that becomes readable on a later tick is signalled there when its identity is proven, SIGKILL after the grace: pins existing behaviour that the doc now describes, so it passes ondevand on this branch.Commands on the head (exit codes):
TMPDIR=/tmp bun test tests/clients/link-route-supervisor.test.ts tests/clients/link-supervisor.test.ts: 101 pass, 0 fail (exit 0).bun run typecheck: exit 0.bun run privacy:scan: exit 0.bun run structure:check: exit 0.TMPDIR=/tmp bun scripts/test.ts --parallel=2 tests/clients tests/server/link-management-routes.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/ci-structure-gate.test.ts tests/ci-workflows/file-size-ratchet.test.ts(206 files, includingtests/clients/link-boundary.test.ts): 3549 pass, 67 skip, 3 fail (exit 1). The 3 failures are the Rust ocx-child tests (tests/clients/link-ocx-child-e2e.test.ts, two cases, and the Rust case oftests/clients/link-ocx-child-conformance.test.ts). They stop before any test code runs, becausecargoon the build machine has no default rustup toolchain. This branch touches no Rust code.NOT RUN: the full
bun run testsuite (the build machine allows focused files only; CI covers the rest); the three Rust ocx-child tests above (no toolchain); the docs-site build (one sentence changed in the English guide); Windows and macOS (a Windows sharing lock is the case the removal fix covers, exercised here through an injected EACCES).Review: two read-only rounds by one independent reviewer (gpt-6.1-terra, xhigh effort). Round 1 found two P2s, both in an optional 64 KiB cap on the pidfile read that this branch first added: one read call can return a short read, and the capped reader also fed the one-route startup path, where an oversized file would have read as no pidfile. The cap was removed in the second commit, and the pidfile reader is identical to
dev. Round 2 found no P0–P3 on the head and ran the two supervisor test files there (101 pass).Checklist