Repository navigation
chore(process): make descendant termination proof deterministic - #131876
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Land-ready proof for source head e2a7e65b1db8101986e1cac78162f7ebc265a0e1. This repairs the fixture's unproven descendant readiness, not production timeout or pipe-drain policy. Real IPC and direct-child exit establish setup; separate SIGTERM receipt/survival and descendant-disappearance assertions prove escalation. Production +0/-0; tests +86/-40. Local proof:
The original full-file failure and the fixed run used the same diagnostic 250 ms startup delay. Negative controls independently failed when post-exit cancellation or SIGKILL was disabled; those diagnostic changes are not in this PR. Fresh Codex autoreview was clean at P0, and the rebased patch matches the reviewed bytes. Exact-head CI 33186830918 passed. Linux job 98902091464 ran the full |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 11:54 AM ET / 15:54 UTC. ClawSweeper reviewWhat this changesThe PR makes the buffered-command descendant-cleanup test deterministic by synchronizing descendant readiness over IPC and checking graceful and forced process-tree termination separately. Merge readinessKeep open. Current main still contains the timing-sensitive fixture, while this PR replaces it with a readiness-synchronized lifecycle proof; it is a maintainer-owned test-only repair awaiting the normal exact-head check completion. Priority: P3 Review scores
Verification
How this fits togetherBuffered command execution starts a process, captures its pipes, enforces deadlines, and terminates its process tree when needed. This test exercises that lifecycle through the public buffered-command helper and observes the spawned parent and descendant. flowchart LR
A[Buffered command test] --> B[Command runner]
B --> C[Spawned parent]
C --> D[Ready descendant]
B --> E[Timeout cancellation]
E --> F[Graceful signal]
F --> G[Forced cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +46. Total +46 across 1 file. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the synchronized fixture and land it after exact-head checks confirm the process test suite; retain the production timeout and termination implementation unchanged. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main's fixture permits its direct child to exit immediately after reporting a PID, while the production runner deliberately retains POSIX tree-cancellation ownership after that exit. The PR body also records a before/after full-file reproduction. Is this the best way to solve the issue? Yes. Synchronizing readiness at the test-fixture boundary directly removes the startup race without widening production timeouts or changing process-tree policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d2cf05c35c1a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Related: #106495 (buffered execution through Execa), #107011 (earlier descendant-test timing adjustment).
What Problem This Solves
Resolves a problem where the buffered process-tree regression test could report a normal exit instead of the expected timeout under process-startup load. This is a maintainer-requested repair of the existing test, not a runtime timeout-policy change.
Why This Change Was Made
The fixture let its direct child exit before the descendant had installed its SIGTERM handler. The normal 100 ms inherited-pipe idle release could then settle Execa and clear the command deadline. Raising the deadline from 50 ms to 500 ms in #107011 did not synchronize that setup.
The fixture now acknowledges readiness over real IPC after installing its handler and a quiet keepalive, observes the direct child's actual exit through the existing pass-through spawn helper, and advances only host deadlines. It separately proves SIGTERM receipt and survival, then descendant disappearance after the existing kill grace. Quiet output prevents EPIPE from masquerading as force-kill proof. Cleanup restores timers and the spy, kills the owned process group, settles the command, and removes temporary artifacts. No production API or implementation changes.
User Impact
No user-visible behavior, configuration, timeout, or runtime changes. Developers get deterministic coverage of cancellation and force-kill after direct-child exit.
Production LOC: +0/-0. Tests: +86/-40 (net +46), entirely in
src/process/exec.test.ts.Evidence
code: 0,termination: exit). The repaired full file passed with that same delay: 40 passed, 1 platform skip. The diagnostic delay is not included in the patch.Local validation after a normal dependency install:
node scripts/check-changed.mjs -- src/process/exec.test.tspassed, including the full dead-export scans, core-test typechecks, and changed-file lint.node scripts/run-tsgo-core-test-shards.mjspassed. The prior local Pako declaration error was an incomplete installation;pnpm installrestored UI Pako 3.0.1 and its bundled declarations without manifest or lockfile edits.node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.other.json --builders 1, targeted oxlint, formatting, andgit diff --checkpassed.After rebasing,
node scripts/run-vitest.mjs src/process/exec.test.ts src/process/child-process.test.ts src/process/exec.no-output-timer.test.ts src/process/kill-tree.test.ts src/process/exec.windows.test.tspassed again: 101 passed, 1 skipped. Targeted core-test types, formatting, andgit diff --checkalso passed. The rebased patch is byte-identical to the reviewed patch.Exact-head CI run 33186830918 passed for
e2a7e65b1db8101986e1cac78162f7ebc265a0e1. The Linux changed-test job ran the fullexec.test.tsfile: 40 passed, 1 skipped, including the repaired descendant case. Native review artifacts validate with zero findings. ClawSweeper review follow-through: latest review reported no code findings. Both remaining items are satisfied: exact-head CI 33186830918 and its Linux process integration job passed; direct local inspection of pinned Execa 10.0.1lib/resolve/wait-subprocess.js:85andlib/resolve/wait-stream.js:87confirmed exit-plus-stream settlement and readable-stream destruction semantics. The reviewer could not inspect its own dependency checkout, but that gap is covered by this direct source inspection and the passing integration run. No production change or additional repair is needed. NativeOPENCLAW_TESTBOX=1 scripts/pr prepare-run 131876passed hosted gates and preserved the exact reviewed head.