Repository navigation
fix(cli): let the dev runner own child shutdown - #138239
Conversation
The JavaScript shim and dev runner both escalated after five seconds. The shim could kill the runner first, leaving its separately detached child alive. Delegate termination to the runner and handle SIGHUP through its existing signal and build-lock lifecycle. Preserve Node execution under Bun and other shim callers' termination behavior. Real process regressions fail before the fix and pass for SIGTERM/SIGHUP. Runner and entrypoint tests, changed-file checks, and independent review pass. A fresh Linux Node 24.19.0 build passes the original Gateway worker restart scenario (Actions 33868737194). Release-note context: source-checkout Gateway shutdown no longer abandons a slow child when the development launcher's shutdown timers race.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Looks correct. One termination owner removes the orphan window; handling SIGHUP through the same lifecycle is consistent.
Adopt the two relevant test-only corrections already landed in #138238 (e7fffcf). Supply the session methods consumed by nested tool observation and classify structured tool failures as AgentSession does. Keep policy-denial and never-entered action/preparer assertions intact. The original file reproduces three failures. All 112 files and 1,666 tests pass after this correction, with complete changed-file gates and independent review. Launcher implementation and release candidate are unchanged.
|
Codex review: blocked before merge. Reviewed September 4, 2026, 8:41 AM ET / 12:41 UTC. ClawSweeper reviewWhat this changesThe PR lets the development runner, rather than its TypeScript shim, own child-process shutdown, adds SIGHUP handling, and adds real-process lifecycle coverage plus already-merged agent-fixture corrections. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: current main still has the competing shim shutdown deadline, while this PR’s run-node-only delegation preserves a single child-group lifecycle owner. No introduced correctness defect was found; normal exact-head checks remain in progress. Priority: P1 Review scores
Verification
How this fits togetherThe source-checkout development launcher starts a Node runner through a TypeScript shim. Shutdown signals pass through the shim to the runner, which must terminate its child process group before a later Gateway start can reuse the state directory. flowchart LR
A[Operator stops development Gateway] --> B[TypeScript launcher shim]
B --> C[Node development runner]
C --> D[Gateway or build child group]
B --> E[Forwarded shutdown signal]
E --> C
C --> F[Graceful and forced cleanup]
F --> G[Restart can acquire state directory]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +74, Other +5. Total +79 across 7 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the explicit run-node handoff so the process-group owner performs all escalation, with the real TERM/HUP lifecycle regression guarding the boundary before merge. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: the added real-process test launches a resistant child, signals the actual launcher PID, then verifies that the child is dead before cleanup. This read-only review did not execute the test. Is this the best way to solve the issue? Yes—the runner is already the owner of the child process group and its existing escalation path, so delegating the shim deadline avoids competing lifecycle owners while preserving the watchdog for other shim callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c3f394f3bda6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* fix(cli): let the dev runner own child shutdown The JavaScript shim and dev runner both escalated after five seconds. The shim could kill the runner first, leaving its separately detached child alive. Delegate termination to the runner and handle SIGHUP through its existing signal and build-lock lifecycle. Preserve Node execution under Bun and other shim callers' termination behavior. Real process regressions fail before the fix and pass for SIGTERM/SIGHUP. Runner and entrypoint tests, changed-file checks, and independent review pass. A fresh Linux Node 24.19.0 build passes the original Gateway worker restart scenario (Actions 33868737194). Release-note context: source-checkout Gateway shutdown no longer abandons a slow child when the development launcher's shutdown timers race. * test(agents): align attempt fixtures with session contracts Adopt the two relevant test-only corrections already landed in openclaw#138238 (ce8b5ca). Supply the session methods consumed by nested tool observation and classify structured tool failures as AgentSession does. Keep policy-denial and never-entered action/preparer assertions intact. The original file reproduces three failures. All 112 files and 1,666 tests pass after this correction, with complete changed-file gates and independent review. Launcher implementation and release candidate are unchanged.
What Problem This Solves
Stopping a source-checkout Gateway could leave its process alive after the development launcher exited. Release validation encountered a restart refusal because the previous Gateway still owned the state directory. A separate real-process reproduction confirmed a launcher defect consistent with that failure: a child that needs forced shutdown survives its launcher and becomes orphaned.
Why This Change Was Made
The JavaScript shim and
runNodeMaineach started a five-second escalation timer, but their child processes occupied different process groups. The outer timer could kill the inner owner before the inner timer cleaned up its own child group.run-node.mjsnow explicitly delegates termination to its implementation. The shim forwards signals and joins that implementation without running a competing deadline.runNodeMainretains its existing five-second cleanup and handles SIGHUP through the same signal/build-lock lifecycle as SIGINT and SIGTERM. This keeps the existing Node implementation under Bun and leaves other shim callers' ownership unchanged.An in-process loader was considered, but it would either move the owner and postbuild work into Bun or introduce a second execution path. Raising the outer deadline would retain competing owners. Explicit delegation is the smaller ownership repair.
User Impact
Source-checkout Gateway shutdown cleans up a slow child before its launcher completes, allowing a subsequent start to acquire the state directory. No configuration, environment variable, protocol, database, dependency, or published CLI option changes.
Release-note context: fix orphaned Gateway processes during development-launcher shutdown and restart.
Evidence
node scripts/run-vitest.mjs test/scripts/run-node-lifecycle.test.ts src/infra/run-node.test.ts— 94 passing cases, in both release and main contexts. The shared direct-entrypoint suite also passed 48 cases.node-worker-launch-wire.e2e.test.tsGateway restart scenario in 86.797 seconds. Production/helper hashes match the final patch; the later test-only change adds an explicit environment type annotation.The original Gateway failure did not reproduce in an earlier unchanged isolated rerun; the launcher orphan is independently proven, but that historical CI failure is not conclusively attributed. This focused proof does not replace full release qualification.
Named sibling follow-up: inspect
run-with-env.mtsandwatch-node.mtssupervision, which have their own outer deadlines, plus managed-child shim users such asrun-oxlint.mjsandcheck-changed.mjs. Those additional wrapper paths were source-audited but are not claimed as repaired by this change.Canonical CI fixture refresh
The first exact-head CI completed with one failed test shard and its aggregate. Three Code Mode denial cases used an incomplete synthetic session: nested observation needed missing
getAppendParentId/appendMessagemethods, and the bare Agent fixture omitted AgentSession's structured-failure classification. The actual denied action and preparer remained unentered.Head
1afa189b693560220dc1816911937a7c3f4ba925adopts only the two relevant test/support files already repaired in #138238, commite7fffcf7a0935ac4abdd6a0efa8bb4dc5a585e6b. The fixture now matches those existing contracts and asserts the exact denial reasons. Other changes from that source PR are not included. All five launcher files are byte-unchanged.The pre-edit file reproduced the same three failures. The complete original test group then passed all 112 files and 1,666 tests, with the original denial-case order retained. The full changed-file gate and managed incremental P0–P2 review pass. This refresh adds 24 and removes 21 test/support lines, zero production lines; the full PR is production +29/−24 (net +5), tests/support +96/−22 (net +74), seven files. The subsequent exact-head CI is green.
Exact-head CI for
1afa189b693560220dc1816911937a7c3f4ba925completed successfully at 12:54:08 UTC on September 4, 2026, including the requiredopenclaw/ci-gate. All attached checks are complete with no failures or pending checks; Workflow Sanity passed and the three Testbox workflow filters do not apply to these changed paths. The completed ClawSweeper review found no introduced correctness defect. Its before-merge request and sole rank-up move were to let these exact-head checks finish, which is now satisfied.