Repository navigation
fix: keep child cleanup failures from crashing the Gateway - #150427
Conversation
Join authority finalization and admitted tree signals into recorded cleanup outcomes. Retain eager run failures until callers request the result, keep cleanup deadlines armed through root settlement and disposal, and serialize bounded redacted error stacks in stability bundles. The 2026.9.4 MCP SDK close path is already contained by #144941 on main. This change covers remaining owner failures established by fault injection. Thanks to itanyplus and waynegault for the reports and field evidence. Related: #144911, #144941.
Record observer failures at the identity-loss owner so cancellation and lineage rejection handlers cannot escape cleanup settlement. Cover cancellation and asynchronous group-poll faults while retaining known root results. Related: #144911.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 6:07 AM ET / 10:07 UTC (Revision 8). ClawSweeper reviewWhat this changesThe PR contains child-cleanup and early supervised-process rejections while preserving caller-visible failures, and adds bounded, redacted stacks to Gateway diagnostic bundles. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still contains the unobserved failure paths, and the earlier MCP fix does not supersede them. No blocking introduced correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe process supervisor manages commands and MCP child processes for OpenClaw. It separates command results from cleanup confirmation, while Gateway stability bundles preserve diagnostic evidence when failures occur. flowchart TD
A[Commands and MCP children] --> B[Spawn transport]
B --> C[Child lifecycle owner]
C --> D[Command result and output]
C --> E[Cleanup confirmation or failure]
E --> F[Supervisor and Gateway callers]
D --> F
F --> G[Redacted diagnostic bundle]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +58, Tests +299, Docs 0. Total +357 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep failure observation with the existing lifecycle owners while preserving command results, truthful cleanup outcomes, existing deadlines, and backward-readable diagnostics. Do we have a high-confidence way to reproduce the issue? Yes, for the source-level defects: rejected finalization, tree-signaling, and eager-result promises have identifiable escape paths, exercised by focused fault-injection regressions. This review did not execute them or reproduce the original Linux/systemd field crash. Is this the best way to solve the issue? Yes. The patch observes failures at their existing owners, preserves cleanup uncertainty, and reuses diagnostic redaction without adding a competing lifecycle or configuration path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 847aef50adf6. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
b91d382 to
b485396
Compare
362eb1f to
2f5eaf7
Compare
…0642) Keep metadata-close Gateway listeners reserved from allocation through startup, preventing intermittent GatewayLockError/EADDRINUSE when another process claims a probed port. The shared fixture transfers the actual HTTP listener to the existing transport and shutdown owners, migrates all three callers, and closes reservations on failed startup or cleanup. Ordinary Gateway startup retains the existing bind/retry path. There are no user-visible or update behavior changes, new options, schema changes, dependency changes, or timeout increases. Related: #150427, whose CI exposed the fixture race but did not cause it. Validation: deterministic collision, real health response, and shutdown port-release regression; focused Linux/macOS fixture proof; HTTP/transport sibling coverage; exact-head CI run 35193350398 green with zero pending checks. Historical unrelated failures remain documented in the PR and were not rerun. Recorded Codex autoreview and exact-head ClawSweeper review found no actionable defects.
2f5eaf7 to
071ce2b
Compare
Merge current main while retaining #150392 control-EOF joining and deferred expiry. Route extinction wait failures through the retained finalization outcome, and revalidate authority after both observational joins before probing the process group. The PR adds no dependency or protocol changes.
071ce2b to
e7afd5f
Compare
|
Merged via squash.
|
Full catalog refreshes could expose provider results before native discovery and its paired auth facts settled, temporarily dropping native model choices. Keep the previous complete catalog, runtime models, and inventory published until the new generation is complete, and restore the previous publication on acquisition failure. Preserve the five-second foreground bound, scoped provider refreshes, and recorded discovery failures. The worker-boundary regression holds native acquisition to exercise concurrent readers and verifies the final merged catalog. Related: #150427 Validation: forced-ordering regressions reproduced the defect on macOS and Linux, then passed 20/20 serial runs per platform with the fix. Catalog/model-selection suites passed 641 tests across 41 files; build and changed checks passed. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/35209693054.
…nclaw#150642) Keep metadata-close Gateway listeners reserved from allocation through startup, preventing intermittent GatewayLockError/EADDRINUSE when another process claims a probed port. The shared fixture transfers the actual HTTP listener to the existing transport and shutdown owners, migrates all three callers, and closes reservations on failed startup or cleanup. Ordinary Gateway startup retains the existing bind/retry path. There are no user-visible or update behavior changes, new options, schema changes, dependency changes, or timeout increases. Related: openclaw#150427, whose CI exposed the fixture race but did not cause it. Validation: deterministic collision, real health response, and shutdown port-release regression; focused Linux/macOS fixture proof; HTTP/transport sibling coverage; exact-head CI run 35193350398 green with zero pending checks. Historical unrelated failures remain documented in the PR and were not rerun. Recorded Codex autoreview and exact-head ClawSweeper review found no actionable defects.
…150427) Keep child cleanup and eager supervised-process failures visible to callers without letting unobserved rejections crash the Gateway. Publish the retained cleanup promise at the sole spawnServiceChildRelay creation site, join authority finalization and admitted tree signaling, and preserve retained-handle escalation, forced-exit diagnostics, output drainage, and cleanup deadlines. Uncertain extinction remains a failure. Include redacted error stacks in Gateway stability bundles, bounded to 8,000 UTF-16 code units; older bundles without stacks remain readable. No configuration, CLI option, dependency, schema version, or installed update-driver behavior changes. The runtime repair takes effect when the candidate Gateway starts. Related: openclaw#144911, openclaw#144941. Preserve integration with openclaw#150306, openclaw#150392, and openclaw#150564. The earlier MCP field-crash path is separately contained by openclaw#144941; this change closes remaining unobserved-promise paths. Thanks to @itanyplus, @waynegault, @chachi-max, and @kip-claw for the reports and field evidence. Validation: exact-head CI run 35208176360 is green. Recorded focused proof: 395 tests passed and 6 skipped, followed by 64 passing spawn-broker tests; check:changed passed. Codex review is scoped-clean through P1 on a patch-identical revision, and ClawSweeper reports no findings on the landed head. Prior macOS Gateway probes predate final broker integration and do not claim a Linux/systemd field-crash reproduction.
…w#150806) Full catalog refreshes could expose provider results before native discovery and its paired auth facts settled, temporarily dropping native model choices. Keep the previous complete catalog, runtime models, and inventory published until the new generation is complete, and restore the previous publication on acquisition failure. Preserve the five-second foreground bound, scoped provider refreshes, and recorded discovery failures. The worker-boundary regression holds native acquisition to exercise concurrent readers and verifies the final merged catalog. Related: openclaw#150427 Validation: forced-ordering regressions reproduced the defect on macOS and Linux, then passed 20/20 serial runs per platform with the fix. Catalog/model-selection suites passed 641 tests across 41 files; build and changed checks passed. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/35209693054.
…Jobs Follow up on #151325 by sharing the stdio-preserving Job launcher between runtime children and tooling. Admit target code only after Job assignment, retain certification after root exit, and preserve worker IPC. Existing non-fatal MCP/LSP cleanup containment from #150427 is unchanged; this extends the ownership work in #150244.
…Jobs Follow up on #151325 by sharing the stdio-preserving Job launcher between runtime children and tooling. Admit target code only after Job assignment, retain certification after root exit, and preserve worker IPC. Existing non-fatal MCP/LSP cleanup containment from #150427 is unchanged; this extends the ownership work in #150244.
Windows owned stdio children now use the existing retained Job owner to confirm descendant cleanup after the parent exits, preserving interactive input and worker IPC. Keep native support optional: unavailable or failed Job setup falls back to ordinary command startup and reports typed uncertainty. Tree-required cleanup retains state locks and temporary artifacts until extinction is certified; transport-only cleanup remains independent. Claude prompt and skill artifacts are retained with a warning when cleanup is uncertain. Related: #151325, #150427, #150244. Validation: exact-head CI run 35354835669 is green, including both Windows node-test jobs; 243 focused tests passed locally on macOS with six native Windows skips. The P1 review is scoped-clean, and all 13 reviewed commits are preserved by a semantic-equivalent rebase. Hosted Windows proof and the capability matrix satisfy the maintainer's compatibility-proof ruling.
…aw#151443) Windows owned stdio children now use the existing retained Job owner to confirm descendant cleanup after the parent exits, preserving interactive input and worker IPC. Keep native support optional: unavailable or failed Job setup falls back to ordinary command startup and reports typed uncertainty. Tree-required cleanup retains state locks and temporary artifacts until extinction is certified; transport-only cleanup remains independent. Claude prompt and skill artifacts are retained with a warning when cleanup is uncertain. Related: openclaw#151325, openclaw#150427, openclaw#150244. Validation: exact-head CI run 35354835669 is green, including both Windows node-test jobs; 243 focused tests passed locally on macOS with six native Windows skips. The P1 review is scoped-clean, and all 13 reviewed commits are preserved by a semantic-equivalent rebase. Hosted Windows proof and the capability matrix satisfy the maintainer's compatibility-proof ruling.
Related: #144911, #144941
What Problem This Solves
Fixes unhandled rejections from child cleanup and early supervised-process failures, and missing error stacks in Gateway stability bundles.
User Impact
Cleanup failures remain visible to their callers without escaping as process-level rejections. Stability bundles retain the error's redacted stack, bounded to 8,000 UTF-16 code units, so subsequent reports identify its origin.
The 2026.9.4 MCP crash path is already contained on main by #144941, which is unreleased and was not included in 2026.9.4. This PR closes the remaining unobserved-promise escape paths and makes dumps carry the producer's stack; it does not claim a new reproduction of that field crash on current main.
Why This Change Was Made
The relay host now retains authority-finalization outcomes and joins them into its published cleanup promise. Its shared identity-loss recorder also settles cleanup when error observers throw, including cancellation and lineage-notification failures. Tree signaling is owned through cleanup, and the supervisor records eager run outcomes before any caller requests them. These changes preserve observed root results, output drainage, repeated cancellation requests, and the existing cleanup deadline. Uncertain extinction remains a failure rather than being reported as successful cleanup.
Stack serialization reuses the existing redaction and shutdown-stack bound. Older bundles without a stack remain readable. No configuration, CLI options, dependencies, schema versions, or update-driver behavior change; the runtime fix takes effect when the Gateway starts on the candidate.
Integration with current main preserves #150392 control-EOF joining and deferred expiry, plus #150306 retained-handle retirement and forced-exit diagnostics. Rejected lineage and polling joins flow through the retained finalization outcome; unexpected finalization failures also release the relay IPC receipt hold. The 30-line
service-child-cleanup.tsmechanism owns completion and finalization observation. Following #150564,spawnServiceChildRelayis its sole creation and publication site: it publishes the retained cleanup promise before broker transport readiness and returns the same object to the host. The host binds finalization to that object and remains the lifecycle owner within the 700-line cap. Cleanup regressions moved unchanged alongside the mechanism and still drive the public relay adapter.Retained-handle escalation and forced-exit diagnostics remain with #150306's retirement mechanism. #149158 covers worker cleanup across crashes and shutdown; this PR preserves those authority decisions.
Thanks to @itanyplus, @waynegault, @chachi-max, and @kip-claw for the reports and field evidence.
Evidence
unhandledRejection: close before/after root result, cancellation notification, and a rejected async group poll. They now return recorded cleanup failures. Tree-signaling and eager-supervisor result failures also failed before the repair and pass afterward.pnpm check:changed: passed, including typechecks, lint, line caps, and all selected guards. Fresh Codex branch review (--mode branch --base origin/main --max-priority P1): scoped-clean at2f5eaf7c1a371ed9a95500a423464ab29b3d8a3a. This review supersedes the earlier review after integration with the broker-owned cleanup creation site.No lazy-loading or worker-entrypoint boundary changed; a build was not required for this revision.