Skip to content

fix(codex): handle stdout/stderr stream errors in CLI session exec resume#102385

Closed
lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix/codex-cli-stream-errors
Closed

fix(codex): handle stdout/stderr stream errors in CLI session exec resume#102385
lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix/codex-cli-stream-errors

Conversation

@lsr911

@lsr911 lsr911 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Codex CLI session exec resume handler spawns a child process and pipes stdout/stderr for data collection, but does not register error handlers on the stdio streams. If a stream errors (e.g. pipe broken, EPIPE), the Promise never settles because only process-level errors (child.on("error")) are caught.

Unhandled stream errors can cause uncaught exceptions or leave the Promise hanging indefinitely.

Why This Change Was Made

Adds child.stdout.on("error", reject) and child.stderr.on("error", reject) inside the Promise constructor alongside the existing child.on("error", reject) to catch stream-level errors.

This follows the same established pattern used by:

Files Changed

File Change
extensions/codex/src/node-cli-sessions.ts +2 lines: child.stdout.on("error", reject) + child.stderr.on("error", reject)

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

…sume

The exec resume child process pipes stdout/stderr for data collection
but does not register error handlers on the stdio streams. If a
stream errors (e.g. pipe broken), the Promise never settles because
only process-level errors are caught.

Add child.stdout.on('error', reject) and child.stderr.on('error',
reject) inside the Promise constructor alongside the existing
child.on('error', reject) to catch stream-level errors.

This follows the same pattern as openclaw#101505 (mushuiyu886), openclaw#101597
(Alix-007), openclaw#101401 (cxbAsDev), and openclaw#101088 (masatohoshino).

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added extensions: codex size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

This PR should close because the same Codex CLI resume stream-error problem is already covered by the open, stronger canonical PR at #102127, which preserves child-process lifecycle and includes real-spawn regression proof while this branch only rejects immediately on stream error.

Root-cause cluster
Relationship: superseded
Canonical: #102127
Summary: The current PR and #102127 target the same runCodexExecResume stdout/stderr stream-error gap; the latter is the canonical open replacement because it preserves child lifecycle and includes proof.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this branch and focus review on #102127 as the canonical implementation for this Codex CLI resume stream-error fix.

So I’m closing this here and keeping the remaining discussion on #102127.

Review details

Best possible solution:

Close this branch and focus review on #102127 as the canonical implementation for this Codex CLI resume stream-error fix.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main has piped stdout/stderr data listeners in runCodexExecResume without stream error listeners, and the canonical replacement PR demonstrates the stream-error path with real-spawn regression tests.

Is this the best way to solve the issue?

No. This branch is only a partial mitigation because it rejects immediately; the better fix is the canonical replacement that terminates the child, waits for exit, and proves the behavior with tests.

Security review:

Security review cleared: No dependency, workflow, secret, package-resolution, or command-source security regression was found in this small child-process error-handling diff.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • mbelinky: Authored merged PR feat(codex): bind CLI sessions from nodes #81747, which introduced node-backed Codex CLI session listing and resume binding including runCodexExecResume. (role: introduced behavior; confidence: high; commits: a5c1956ca17a; files: extensions/codex/src/node-cli-sessions.ts, extensions/codex/index.ts)
  • vincentkoc: Recently touched node-cli-sessions.ts for node proxy payload handling and merged the adjacent Codex app-server stdio stream-error fix. (role: recent area contributor and adjacent merger; confidence: medium; commits: c70adb8528f8, 846195c6b001; files: extensions/codex/src/node-cli-sessions.ts, extensions/codex/src/app-server/client.ts)
  • llagy009: Recently maintained node-cli-sessions.ts preview handling in merged PR fix(codex): keep CLI session preview text on code-point boundaries #96582, though not the child-process lifecycle path. (role: recent same-file contributor; confidence: medium; commits: b5c662f4f54c; files: extensions/codex/src/node-cli-sessions.ts, extensions/codex/src/node-cli-sessions.test.ts)
  • wangmiao0668000666: Authored the open canonical replacement PR that covers this exact stream-error lifecycle with tests and real behavior proof. (role: canonical replacement author; confidence: medium; commits: 5bc1256617de; files: extensions/codex/src/node-cli-sessions.ts, extensions/codex/src/node-cli-sessions.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 1017ea5bc804.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 9, 2026
@lsr911

lsr911 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by wangmiao0668000666's #102127 which provides a more complete fix with real-spawn regression proof and proper child-process lifecycle preservation.

@lsr911 lsr911 closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant