Skip to content

fix(node-host): drain all workers before shutdown failures - #129699

Merged
steipete merged 1 commit into
mainfrom
codex/node-worker-supervisor-shutdown-drain
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/node-worker-supervisor-shutdown-drain

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • wait for every active remote node worker to finish container/process teardown before surfacing shutdown failures
  • preserve the existing exact single-error versus aggregate-error contract and reconcile healthy sibling ownership before the host can exit
  • cover a failed first Docker removal plus a healthy sibling whose actual fake-engine removal remains blocked; production delta is exactly zero lines

Root cause

NodeWorkerSupervisor.close() used fail-fast Promise.all across independent worker stops. If one Docker container removal rejected while another removal was still in flight, supervisor shutdown rejected immediately. The terminal Gateway reconnect handler calls activeRuntime.close().finally(() => process.exit(code)), so that premature rejection could forcibly exit the node host and orphan the still-running healthy container.

The supervisor now joins every stop with Promise.allSettled, collects failures in its existing owner-local error accumulator, completes terminal reconciliation, and preserves the original single-error/AggregateError behavior. This matches the existing parent runtime shutdown contract without adding production lines, configuration, compatibility paths, or test-only seams.

Verification

  • Failing-before owner proof: the new two-container regression observed supervisor shutdown reject with the first injected removal error while the healthy sibling's existing fake Docker rm was deliberately held.
  • Passing-after exact-tree proof: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/node-host/node-worker-supervisor.container.test.ts src/node-host/node-worker-supervisor.test.ts src/node-host/runtime.test.ts src/node-host/runner.test.ts --reporter=dot — four files, 111 tests passed, including real runner terminal reconnect/exit behavior.
  • The new regression verifies the healthy Docker container remains present while removal is blocked, shutdown stays pending despite its sibling's failure, the healthy container is then removed and durably marked interrupted, and the failed container remains authoritatively running until retry cleanup.
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs --timed -- src/node-host/node-worker-supervisor.ts src/node-host/node-worker-supervisor.container.test.ts — all 28 changed-file, typecheck, lint, boundary, and security stages passed.
  • Fresh structured independent autoreview: clean.
  • git diff --numstat: production +7/-7 (net zero); regression test +68.

Related remote-node live Docker/Gateway/Chromium proof and Full Access approval repair: #129674.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete merged commit 68e7942 into main Aug 26, 2026
136 checks passed
@steipete
steipete deleted the codex/node-worker-supervisor-shutdown-drain branch August 26, 2026 00:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant