nikivdev/code · error
codex app-server closed stdout unexpectedly
Error message
codex app-server closed stdout unexpectedly
What it means
The codex app-server reader thread signaled that the process closed its stdout (CodexAppServerEvent::Closed). Since the tool expects an ongoing JSON-RPC conversation, an unexpected EOF means the codex process exited or terminated its output stream and the operation must fail.
Source
Thrown at src/commit.rs:4728
if now >= deadline {
return Ok(CodexReadOutcome::TimedOut);
}
let wait = cmp::min(
Duration::from_millis(250),
deadline.saturating_duration_since(now),
);
match rx.recv_timeout(wait) {
Ok(CodexAppServerEvent::Line(line)) => {
if line.trim().is_empty() {
continue;
}
let msg: serde_json::Value = serde_json::from_str(&line)
.with_context(|| format!("invalid JSON from codex: {}", line))?;
return Ok(CodexReadOutcome::Message(msg));
}
Ok(CodexAppServerEvent::ReadError(err)) => bail!("failed to read from codex: {}", err),
Ok(CodexAppServerEvent::Closed) => bail!("codex app-server closed stdout unexpectedly"),
Err(RecvTimeoutError::Timeout) => continue,
Err(RecvTimeoutError::Disconnected) => bail!("codex app-server reader disconnected"),
}
}
}
/// Read lines until a JSON-RPC response with the expected id arrives.
fn codex_read_response(
rx: &std::sync::mpsc::Receiver<CodexAppServerEvent>,
expected_id: u64,
deadline: std::time::Instant,
) -> Result<serde_json::Value> {
loop {
let msg = match codex_read_next_message(rx, deadline)? {
CodexReadOutcome::Message(msg) => msg,
CodexReadOutcome::TimedOut => bail!("codex app-server response timed out"),
};
if msg.get("id").and_then(|id| id.as_u64()) == Some(expected_id) {View on GitHub (pinned to a747e741ae)
Solutions
- Inspect the codex process stderr/logs for the reason it exited.
- Verify codex configuration and authentication, then restart the flow.
- Re-run the command after confirming codex stays up (watch the process while it runs).
- Update or reinstall the codex binary if crashes are reproducible.
Defensive patterns
Strategy: try-catch
Try / catch
match codex_review() {
Err(e) if e.to_string().contains("closed stdout unexpectedly") => {
// capture codex stderr/logs, restart codex, then retry once
}
other => other?,
} Prevention
- Capture codex stderr to logs so exit causes are diagnosable.
- Validate codex config/auth before starting long review sessions.
- Upgrade codex if crashes are reproducible with your workload.
When it happens
Trigger: Waiting for JSON-RPC messages from codex when the reader reports stdout closed — i.e., the codex app-server process exited while the tool was mid-conversation.
Common situations: Codex crashed (panic, OOM kill); user or system stopped the process; codex exited early due to invalid config or auth failure; version mismatch causing protocol abort.
Related errors
- failed to read from codex: {}
- native session bridge warm command failed with status {}
- codex app-server reader disconnected
- codex app-server response timed out
- codex app-server response timed out
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/5852b41e6a4bfabd.
Report an issue: GitHub.