Skip to content

fix(codex): handle app-server stdio stream errors#101505

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
mushuiyu886:fix/followup-67947
Jul 7, 2026
Merged

fix(codex): handle app-server stdio stream errors#101505
vincentkoc merged 1 commit into
openclaw:mainfrom
mushuiyu886:fix/followup-67947

Conversation

@mushuiyu886

@mushuiyu886 mushuiyu886 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Prevents asynchronous Codex app-server stdio stream errors from becoming unhandled Node errors that can terminate the gateway.

Why This Change Was Made

CodexAppServerClient already owns child-process, exit, and stdin pipe failures. It did not own errors from the readline interface, stdout stream, or stderr stream.

The submitted patch treated all three streams as terminal. Maintainer review corrected that boundary:

  • readline and stdout errors close the client, reject pending RPC requests, and preserve the original close reason;
  • stderr errors are logged without closing an otherwise healthy RPC connection.

This matches the upstream Codex transport contract: codex-rs/app-server-transport/src/transport/stdio.rs carries newline-delimited JSON-RPC on stdout, while codex-rs/app-server/src/lib.rs configures tracing output on stderr.

User Impact

A broken stdout RPC pipe now fails pending Codex requests cleanly instead of risking an unhandled process error. Losing only stderr diagnostics no longer aborts healthy Codex turns.

Evidence

Focused local proof:

Test Files  1 passed (1)
Tests       31 passed (31)

Testbox-through-Crabbox:

provider: blacksmith-testbox
lease: tbx_01kwxzcqc0ah5kegxbk6b73z8p
focused Codex client tests: 31 passed
pnpm build: passed
pnpm check:changed: passed on the cleaned current-main branch

Fresh autoreview completed with no accepted or actionable findings. The test proves that stdout failure rejects pending and later requests, while stderr failure is logged and two consecutive RPC requests still resolve.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 5:07 AM ET / 09:07 UTC.

Summary
The PR adds stdout readline, stdout stream, and stderr stream error handling to CodexAppServerClient, plus regression tests for stdout and stderr stream errors.

PR surface: Source +9, Tests +26. Total +35 across 2 files.

Reproducibility: yes. from source and PR proof: current main owns stdin and child process errors but not stdout/readline/stderr error events, and the PR body includes red-test and real app-server stdio output showing the failure boundary. I did not rerun the tests locally in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The PR is behind current main, so final merge should use exact-head CI after any required branch refresh; GitHub still reports the branch mergeable.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused owner-boundary fix after normal exact-head checks, keeping stream failures on the centralized CodexAppServerClient closeWithError path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair job is needed; the PR is reviewable as-is with no blocking findings, pending normal exact-head merge checks and any branch refresh.

Security
Cleared: The diff only adds Codex plugin client stream error listeners and tests; it does not change dependencies, CI, secrets, auth, config, or code-execution policy.

Review details

Best possible solution:

Land the focused owner-boundary fix after normal exact-head checks, keeping stream failures on the centralized CodexAppServerClient closeWithError path.

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

Yes, from source and PR proof: current main owns stdin and child process errors but not stdout/readline/stderr error events, and the PR body includes red-test and real app-server stdio output showing the failure boundary. I did not rerun the tests locally in this read-only review.

Is this the best way to solve the issue?

Yes. Routing read and diagnostic stream errors through CodexAppServerClient.closeWithError is the narrow owner-boundary fix; a no-op listener would avoid throws but would lose pending-request rejection and close-reason preservation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 13c1d3c4083a.

Label changes

Label changes:

  • add P2: This is a focused Codex app-server crash hardening fix with limited blast radius and no evidence of a current widespread release-blocking incident.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live output from a real Codex app-server stdio child process plus a real Codex model proof, with the stream-error behavior and improved result shown in terminal output.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix live output from a real Codex app-server stdio child process plus a real Codex model proof, with the stream-error behavior and improved result shown in terminal output.

Label justifications:

  • P2: This is a focused Codex app-server crash hardening fix with limited blast radius and no evidence of a current widespread release-blocking incident.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix live output from a real Codex app-server stdio child process plus a real Codex model proof, with the stream-error behavior and improved result shown in terminal output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live output from a real Codex app-server stdio child process plus a real Codex model proof, with the stream-error behavior and improved result shown in terminal output.
Evidence reviewed

PR surface:

Source +9, Tests +26. Total +35 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 0 +9
Tests 1 26 0 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 35 0 +35

What I checked:

Likely related people:

What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@vincentkoc
vincentkoc force-pushed the fix/followup-67947 branch from ec64376 to 7c95f14 Compare July 7, 2026 10:25
@vincentkoc vincentkoc self-assigned this Jul 7, 2026
@vincentkoc vincentkoc changed the title fix(codex): close app-server client on stdio stream errors fix(codex): handle app-server stdio stream errors Jul 7, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Maintainer repair is pushed at 7c95f145124d60f635a4a1d79608b85d4939f48a.

The submitted stderr behavior was corrected. Codex stdout is the JSON-RPC transport, so readline/stdout errors close the client and reject pending requests. Stderr is the upstream tracing channel, so its errors are logged without killing healthy RPC.

The stale fork lineage was also replaced with one contributor-authored commit on current main, touching only:

  • extensions/codex/src/app-server/client.ts
  • extensions/codex/src/app-server/client.test.ts

Proof completed:

  • focused local client test - 31 passed
  • Testbox-through-Crabbox tbx_01kwxzcqc0ah5kegxbk6b73z8p - focused 31 tests passed
  • same Testbox - pnpm build passed
  • same Testbox, after cleaning the branch - pnpm check:changed passed
  • fresh autoreview - no accepted/actionable findings

Direct upstream contract checked:

  • ../codex/codex-rs/app-server-transport/src/transport/stdio.rs
  • ../codex/codex-rs/app-server/src/lib.rs

The exact pushed head is running hosted CI.

@vincentkoc
vincentkoc merged commit 846195c into openclaw:main Jul 7, 2026
99 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 8, 2026
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
maweibin added a commit to maweibin/openclaw that referenced this pull request Jul 10, 2026
…cution

Add error handlers for child.stdout and child.stderr streams in
runProcess() to prevent unhandled 'error' events from crashing the
sandbox exec server.

stdout stream errors are treated as fatal (consistent with the existing
child.on('error') handler). stderr stream errors are logged as warnings
(stderr is diagnostic; losing it must not kill an otherwise healthy
process, matching the pattern in openclaw#101505).

Ref: openclaw#101505 (fix(codex): handle app-server stdio stream errors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants