Repository navigation
fix: openclaw node worker never exits after a stop when stdin is held open or a plugin child pins the event loop - #135665
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
…les remain runNodeHostWorker set process.exitCode after stop and relied on the event loop draining. Its own stdin pipe keeps reading while the supervisor still holds the writer, and a plugin-owned child (codex app-server) keeps ref'd pipes past runtime.close(), so the worker never exited on its own. Request the canonical one-shot CLI exit once the worker has stopped, after runtime.close() finished, so the shared finalizer drains stdio and exits.
ec1ca5c to
69dc4ef
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 1:31 AM ET / 05:31 UTC. ClawSweeper reviewWhat this changesThis PR makes the private Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open pending maintainer confirmation of the deliberate shutdown boundary: after successful node-host cleanup, the private worker exits even if unrelated referenced handles remain. The patch otherwise uses the existing CLI finalizer and has no concrete correctness finding. Priority: P1 Review scores
Verification
How this fits togetherThe private node-host worker receives JSONL stop frames from the macOS app or another supervisor, closes its node-host runtime, and returns through the CLI entrypoint. The shared CLI finalizer drains output and terminates the process, preventing stdin or a child process from holding a stopped worker alive. flowchart LR
A[Supervisor] -->|Stop frame or signal| B[Private node worker]
B --> C[Close node-host runtime]
C --> D[Shared CLI finalizer]
D --> E[Drain stdout and stderr]
E --> F[Process exits]
G[Open stdin or child handles] -.cannot pin stopped worker.-> F
Decision needed
Why: This is an intentional availability tradeoff rather than an accidental implementation detail: it prevents an indefinitely stuck worker but stops waiting for handles outside the runtime's cleanup ownership. Before merge
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +70. Total +74 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Confirm successful Do we have a high-confidence way to reproduce the issue? Yes: the supplied built-process before/after trace exercises a stop frame with stdin held open, and current-main source confirms the worker returns without requesting the finalizer. Is this the best way to solve the issue? Yes, conditionally: the patch reuses the canonical CLI exit mechanism at the worker lifecycle owner; only acceptance of the stated terminal-boundary tradeoff remains. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bc4fc0142a1f. LabelsLabel 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
HistoryReview history (4 earlier review cycles)
|
# Conflicts: # test/vitest/vitest.cli-process-paths.mjs
|
Thanks @Colton-Harris! Proof: The built
Landed: 64bcb0c Source: 1658cce |
A stopped private node worker now requests the canonical CLI finalizer after runtime cleanup. A supervisor-held stdin writer or plugin child can no longer keep the completed worker alive. The regression runs the built `openclaw.mjs node worker` path, keeps stdin open after the stop frame, and requires a clean exit. Closes openclaw#135661 Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #135661
Related: #135660 / #135663 (the separate macOS process-group fix)
What Problem This Solves
openclaw node workeracknowledged a stop but could remain alive forever. The normal macOS supervisor keeps the stdin writer open until the worker exits. A plugin-owned child can also keep referenced pipes open during shutdown.Current main
4e36c68976a9474e6c7bf6dc55e2aedb4321d54dreproduced both failures through the built worker command. Each worker remained alive after 2.5 seconds and required cleanup.Why This Change Was Made
runNodeHostWorkeralready closes the bridge, awaitsruntime.close(), records the exit code, and removes its signal handlers. It then returned and relied on Node's event loop to drain. That cannot finish while the supervisor still owns the stdin writer.The worker now requests the existing one-shot CLI finalizer after its shutdown promise settles. The request records terminal intent. The top-level CLI still completes shared resource and harness disposal before it drains stdout/stderr and exits, so plugin children are not hidden by an early
process.exit().This accepts the intentional availability tradeoff named by ClawSweeper: after owned cleanup completes, unrelated referenced handles no longer keep a stopped worker alive.
User Impact
Stopping the private node worker now ends the process promptly. Stop frames keep exit code 0.
SIGTERMkeeps exit code 143.Evidence
Real built-process proof used the same isolated Linux Node 24 environment for current main and the reviewed candidate.
SIGTERM; declared plugin childRegression coverage now drives
openclaw.mjs node workeras a real child process. It waits for the worker's ready frame, sends a stop frame without closing stdin, and requires exit code 0. The test failed on exact main withworker stayed alive after stop while stdin remained openand passed on the reviewed head.Focused validation:
oxfmt --checkand targetedoxlint— passed.Original fix by @Colton-Harris. Maintainer proof and regression repair by @obviyus.