BigPizzaV3/CodexPlusPlus · error

等待 Codex 回复超时

Error message

等待 Codex 回复超时

What it means

run_turn reads JSON-RPC messages from the Codex app-server in a loop until both a response for the turn/start call and a completion status are seen, under a 600-second TURN_TIMEOUT deadline. If the deadline expires before the turn completes, it throws this error. It protects the caller from hanging forever when Codex stops responding.

Solutions

  1. Retry the turn; for consistently long turns check whether a newer Codex CLI handles the task faster or split the task into smaller prompts
  2. Check that the Codex CLI version is compatible (protocol events recognized); upgrade the CLI
  3. Check stderr/logs of the app-server process for a crash or deadlock and restart the CodexAppServer
Defensive patterns

Strategy: retry

Try / catch

let mut attempts = 0;
loop {
    match server.run_turn(prompt).await {
        Ok(r) => break Ok(r),
        Err(e) if e.to_string().contains("超时") && attempts < 1 => {
            attempts += 1;
            server = CodexAppServer::start(config.clone()).await?;
        }
        Err(e) => break Err(e),
    }
}

Prevention

When it happens

Trigger: CodexAppServer::run_turn called while the app-server process is wedged, deadlocked, or busy beyond 600s; turn never emits thread/status/changed idle or the response for turn/start; slow model / very long turn exceeding TURN_TIMEOUT; server crash without emitting a terminal message.

Common situations: Extremely long-running coding tasks exceeding the 10-minute limit, Codex app-server hung on a stuck subprocess, protocol mismatch so the completion event is never recognized, machine sleep/suspend interrupting the pipe.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/d25adb3ab7901dea. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/connect/app_server.rs:222

        }
        self.write_json(&json!({
            "jsonrpc": "2.0",
            "id": id,
            "method": "turn/start",
            "params": params
        }))
        .await?;

        let mut response_received = false;
        let mut turn_completed = false;
        let mut reply_parts = Vec::new();
        let mut model = self.config.model.trim().to_string();
        let mut usage = TurnUsage::default();
        let deadline = tokio::time::Instant::now() + TURN_TIMEOUT;
        while !response_received || !turn_completed {
            let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());
            if remaining.is_zero() {
                bail!("等待 Codex 回复超时");
            }
            let message = self.read_message(remaining).await?;
            if is_server_request(&message) {
                self.reject_server_request(&message).await?;
                continue;
            }
            if response_id(&message) == Some(id) {
                if let Some(error) = rpc_error(&message) {
                    bail!("Codex turn/start 失败:{error}");
                }
                let result = message.get("result").cloned().unwrap_or(Value::Null);
                if extract_turn_id(&result).is_none() {
                    bail!("Codex turn/start 未返回 turn id");
                }
                if model.is_empty() {
                    model = extract_model(&result).unwrap_or_default();
                }
                if let Some(reported_usage) = extract_turn_usage(&result) {

View on GitHub (pinned to b1ed92e5e4)