nikivdev/code · error

codex app-server reader disconnected

Error message

codex app-server reader disconnected

What it means

The channel from the codex stdout reader thread was disconnected (RecvTimeoutError::Disconnected), meaning the reader thread has terminated and no further events will arrive. The tool bails because the JSON-RPC conversation with codex can no longer make progress.

Source

Thrown at src/commit.rs:4730

        }

        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) {
            if let Some(err) = msg.get("error") {
                bail!(

View on GitHub (pinned to a747e741ae)

Solutions

  1. Re-run the command to restart the codex app-server and its reader thread.
  2. Check codex process health/logs to find why the reader shut down.
  3. Look for panics or errors in the tool's output from the reader thread.
  4. Update the tool/codex if a known protocol mismatch causes reader shutdown.
Defensive patterns

Strategy: retry

Try / catch

match codex_review() {
    Err(e) if e.to_string().contains("reader disconnected") => {
        // reader thread died: restart the app-server session and retry once
    }
    other => other?,
}

Prevention

When it happens

Trigger: Blocking on codex_read_next_message with a recv_timeout when the reader thread has already exited (after a read error, EOF, or thread panic), so the channel is closed.

Common situations: Codex process died causing reader thread teardown; reader thread panicked on malformed input; internal concurrency bug shutting down the reader while a request is pending.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/32701aa7eb510626. Report an issue: GitHub.