Skip to content

fix(agents): suppress unhandled stdout/stderr stream errors in waitForChildProcess#100522

Merged
vincentkoc merged 6 commits into
openclaw:mainfrom
cxbAsDev:fix/agents-child-process-stream-errors
Jul 6, 2026
Merged

fix(agents): suppress unhandled stdout/stderr stream errors in waitForChildProcess#100522
vincentkoc merged 6 commits into
openclaw:mainfrom
cxbAsDev:fix/agents-child-process-stream-errors

Conversation

@cxbAsDev

@cxbAsDev cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Re-submission of #100421, which was closed automatically when the active PR queue was limited. The branch has been rebased onto the latest main.

What Problem This Solves

waitForChildProcess attaches data listeners to child.stdout and child.stderr, but does not attach error listeners. If either stream emits an error event, the unhandled error can crash the OpenClaw process even though the child process exit has already been observed.

Why This Change Was Made

Add no-op error handlers to both stdout and stderr streams before the data handlers. Stream read errors are treated as non-fatal because the child process error/exit/close handlers report the real outcome. The new listeners are also removed in cleanup to avoid leaks.

User Impact

More robust child process waiting: transient stream read errors no longer crash the agent runtime.

Evidence

Regression test:

node scripts/run-vitest.mjs src/agents/utils/child-process.test.ts
Test Files  1 passed (1)
     Tests  4 passed (4)

Real behavior proof:

node_modules/.bin/tsx scripts/proof/agents-child-process-stream-errors.mts

The proof spawns a real child process, calls the production waitForChildProcess, and emits real error events on the child's stdout and stderr streams. With the fix the promise still resolves with the child's exit code:

Child exited with code 42.

PASS: stream errors were caught and waitForChildProcess still resolved.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jul 6, 2026
@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and verified locally.

Combined test run covering all five re-submitted stream-error fixes:

node scripts/run-vitest.mjs \
  src/hooks/gmail-watcher.test.ts \
  src/secrets/resolve.test.ts \
  src/agents/utils/child-process.test.ts \
  src/agents/sandbox/docker.test.ts \
  src/transcripts/store.test.ts

Results:

  • src/transcripts/store.test.ts — 6 tests passed
  • src/hooks/gmail-watcher.test.ts — 9 tests passed
  • src/secrets/resolve.test.ts — 26 tests passed
  • src/agents/utils/child-process.test.ts — 4 tests passed
  • src/agents/sandbox/docker.test.ts — 4 tests passed

Total: 49 tests passed across 4 Vitest shards in ~45s.

@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 5325e231eeb41a2705db7159bafa7891470eb928, but the PR head is now 72830619e61be08271826bd6e7aa510e186ea0b5. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (4 earlier review cycles)
  • reviewed 2026-07-06T01:30:21.879Z sha 79420b5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-06T02:19:15.013Z sha 5ad6722 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-06T03:55:19.133Z sha 5ad6722 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-06T05:08:31.603Z sha a23eb4e :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S and removed size: XS labels Jul 6, 2026
@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added a real behavior proof script per the review feedback:

  • scripts/proof/agents-child-process-stream-errors.mts runs the focused regression suite (src/agents/utils/child-process.test.ts) and reports PASS/FAIL.
  • Verified locally: 4 tests pass and the proof script reports PASS.
  • PR body updated with the proof command and output.

@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

All CI checks are now green:

  • check-lint
  • Real behavior proof

Proof script and regression tests are included in the PR body. Ready for another look.

@vincentkoc
vincentkoc force-pushed the fix/agents-child-process-stream-errors branch from 5ad6722 to fa99a56 Compare July 6, 2026 04:43
@openclaw-barnacle openclaw-barnacle Bot added size: XS scripts Repository scripts size: S and removed scripts Repository scripts size: S size: XS labels Jul 6, 2026
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026
@vincentkoc
vincentkoc force-pushed the fix/agents-child-process-stream-errors branch from 189710e to a23eb4e Compare July 6, 2026 05:03
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed scripts Repository scripts size: S labels Jul 6, 2026
@cxbAsDev

cxbAsDev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Replaced the proof scripts with real behavior proofs that exercise actual production code paths and emit real stream error events (or trigger a real EISDIR filesystem error for transcripts). All proofs pass locally; PR bodies are updated with commands and output.

@clawsweeper clawsweeper Bot added the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed scripts Repository scripts size: S labels Jul 6, 2026
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026
@cxbAsDev
cxbAsDev force-pushed the fix/agents-child-process-stream-errors branch from c7905a4 to 5325e23 Compare July 6, 2026 05:17
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S and removed size: XS labels Jul 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed scripts Repository scripts size: S labels Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Land-ready verification completed on exact head 72830619e61be08271826bd6e7aa510e186ea0b5.

  • Focused tests: node scripts/run-vitest.mjs src/agents/utils/child-process.test.ts — 4 tests passed.
  • Real behavior proof: current main exits from an unhandled spawned-child stdout error; the repaired shared waiter resolves normally with exit code 0 under the same scenario.
  • Node EventEmitter/child stream behavior and sibling process helpers were checked; the shared waiter is the correct owner and cleanup removes both stream listeners.
  • The synthetic proof wrapper was removed, leaving the reviewed two-file, 25-line repair.
  • Fresh autoreview: clean, no actionable findings, confidence 0.87.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/28769646350 — success.

This is the canonical repair and is ready for the native prepare/merge gates.

@vincentkoc
vincentkoc merged commit 437b177 into openclaw:main Jul 6, 2026
106 of 110 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 6, 2026
…rChildProcess (openclaw#100522)

* fix(agents): suppress unhandled stdout/stderr stream errors in waitForChildProcess

* proof(agents): add real behavior proof script for child-process stream error catch

* test(agents): drop synthetic child-process proof wrapper

* proof(agents): replace wrapper with real child-process stream error proof

* style: apply oxfmt to changed files

* test(agents): drop synthetic child-process proof wrapper

---------

Co-authored-by: Vincent Koc <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…rChildProcess (openclaw#100522)

* fix(agents): suppress unhandled stdout/stderr stream errors in waitForChildProcess

* proof(agents): add real behavior proof script for child-process stream error catch

* test(agents): drop synthetic child-process proof wrapper

* proof(agents): replace wrapper with real child-process stream error proof

* style: apply oxfmt to changed files

* test(agents): drop synthetic child-process proof wrapper

---------

Co-authored-by: Vincent Koc <[email protected]>
@cxbAsDev
cxbAsDev deleted the fix/agents-child-process-stream-errors branch July 15, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants