Skip to content

fix(link): warn once when a stopped one-route child's exit stays unseen, and describe the tunnel drain accurately - #8643

Merged
lidge-jun merged 3 commits into
devfrom
chore/link-drain-wording-and-tests
Nov 13, 2026
Merged

lidge-jun merged 3 commits into
devfrom
chore/link-drain-wording-and-tests

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

The last nits from the final review of #8640 (issue #8609).

A stopped one-route child whose exit was never seen said nothing. Since #8640, the tick sends a failed link's running one-route child SIGTERM and, 2 s later, SIGKILL, and keeps it until its exit is seen. If even SIGKILL produced no observed exit, the link stayed failed with its old reason, a past retry time and a pid, and nothing was logged. A multi-route candidate in the same position already shows routeBlocked: stop_unconfirmed with a warning. The tick now warns once, [link] tunnel exit unconfirmed link=<id> (link id only), when the exit is still unseen 4 s (2 x CANDIDATE_KILL_GRACE_MS) after the SIGTERM. The link stays failed and owned, as before.

The drain is for any tunnel child. stopChild drains every entry of the supervisor's children: one-route tunnels, multi-route candidates and proven multi-route tunnels. Since #8640 each of them gets SIGKILL from the tick after a 2 s grace on reload, removal, reconnect and shutdown, where before the stop waited forever. The comments in src/link/supervisor.ts and the sentence in structure/remote-link.md said "one-route". They now say any tunnel child and state the timing per case:

  • The grace counts from the drain's SIGTERM.
  • A one-route child the tick had already stopped keeps the tick's stop time, and gets no second SIGKILL if the tick already sent one.
  • A multi-route candidate that route-rounds had already stopped starts a fresh grace. Its SIGKILL can therefore come later than 2 s after its first SIGTERM, and one route-rounds already halted with SIGKILL gets a second, harmless one on the same unreaped process.
  • The stop still waits for the exit to be observed, so a process whose exit is never seen still holds the lifecycle queue.

Carrying route-rounds' own stop time and kill flag into the drain would need that private round state exposed, which is more than the one-line change the review allowed for, so it is left as described.

Tests. The test of a drain on a child the tick already stopped ran the tick stop and the reload at the same clock, so a drain that reset its stop time would also have passed. It is replaced by two tests:

  • A reload 1.5 s after the tick stop: SIGKILL comes exactly 500 ms later.
  • A reload after the tick's own SIGKILL: exactly one SIGKILL.

Two stale comments in an older test are reworded. The tick no longer removes the pidfile there; the exit watch does, after the test tunnel exits on SIGTERM.

What keeps this inert. The only behaviour change is one warning line, for a one-route child whose exit stays unseen 4 s after its SIGTERM. Everything else is comments, documentation and tests.

Verification

In tests/clients/link-route-supervisor.test.ts:

Commands (exit codes):

  • On the head: TMPDIR=/tmp bun scripts/test.ts --parallel=2 tests/clients/link-route-supervisor.test.ts tests/clients/link-supervisor.test.ts tests/clients/link-boundary.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/ci-structure-gate.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts: 214 pass, 0 fail (exit 0).
  • On the head: bun run typecheck: exit 0. bun run privacy:scan: exit 0. bun run structure:check: exit 0.
  • On 60a591b, the only code commit; the two after it change only structure/remote-link.md: 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 (214 files): 3665 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 of tests/clients/link-ocx-child-conformance.test.ts). They stop before any test code runs, because cargo on the build machine has no default rustup toolchain. This branch touches no Rust code.

NOT RUN: the full bun run test suite (the build machine allows focused files only; CI covers the rest); the three Rust ocx-child tests above (no toolchain); Windows and macOS (one warning line and documentation only).

Review: three read-only rounds by one independent reviewer (gpt-6.1-terra, xhigh effort). Rounds 1 and 2 each found a P2 in the drain-timing sentence of structure/remote-link.md:

  • it ignored a one-route child's kept stop time and an exit that is never observed
  • it ignored a stopped candidate's fresh grace

Both are fixed. Round 3 found no P0–P2 through the head. Round 1 ran the two supervisor test files on the code commit (119 pass) and confirmed that the warning carries only the link id.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

…en, and say the drain covers any tunnel child

A one-route child the tick stopped whose exit is still unseen 4 s after the
SIGTERM (after its SIGKILL) now logs '[link] tunnel exit unconfirmed link=<id>'
once, as a halted candidate does; the link stays failed and owned. The drain
comments and structure/remote-link.md say any tunnel child, since stopChild
drains multi-route candidates and proven tunnels too. Tests: the tick-stopped
drain case now reloads 1.5 s after the tick stop and after the tick's own
SIGKILL, so a drain that reset its stop time fails; stale test comments reworded.

Refs #8609
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 13, 2026
@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 04:34
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 04:34
@lidge-jun
lidge-jun merged commit d6ab332 into dev Nov 13, 2026
28 checks passed
@lidge-jun
lidge-jun deleted the chore/link-drain-wording-and-tests branch November 13, 2026 04:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T04:36:14.476946Z c4788c5 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant