{"record":{"id":"d25adb3ab7901dea","repo":"BigPizzaV3/CodexPlusPlus","slug":"codex","errorCode":null,"errorMessage":"等待 Codex 回复超时","messagePattern":"等待 Codex 回复超时","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/connect/app_server.rs","lineNumber":222,"sourceCode":"        }\n        self.write_json(&json!({\n            \"jsonrpc\": \"2.0\",\n            \"id\": id,\n            \"method\": \"turn/start\",\n            \"params\": params\n        }))\n        .await?;\n\n        let mut response_received = false;\n        let mut turn_completed = false;\n        let mut reply_parts = Vec::new();\n        let mut model = self.config.model.trim().to_string();\n        let mut usage = TurnUsage::default();\n        let deadline = tokio::time::Instant::now() + TURN_TIMEOUT;\n        while !response_received || !turn_completed {\n            let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());\n            if remaining.is_zero() {\n                bail!(\"等待 Codex 回复超时\");\n            }\n            let message = self.read_message(remaining).await?;\n            if is_server_request(&message) {\n                self.reject_server_request(&message).await?;\n                continue;\n            }\n            if response_id(&message) == Some(id) {\n                if let Some(error) = rpc_error(&message) {\n                    bail!(\"Codex turn/start 失败：{error}\");\n                }\n                let result = message.get(\"result\").cloned().unwrap_or(Value::Null);\n                if extract_turn_id(&result).is_none() {\n                    bail!(\"Codex turn/start 未返回 turn id\");\n                }\n                if model.is_empty() {\n                    model = extract_model(&result).unwrap_or_default();\n                }\n                if let Some(reported_usage) = extract_turn_usage(&result) {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/connect/app_server.rs#L204-L240","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the turn; for consistently long turns check whether a newer Codex CLI handles the task faster or split the task into smaller prompts","Check that the Codex CLI version is compatible (protocol events recognized); upgrade the CLI","Check stderr/logs of the app-server process for a crash or deadlock and restart the CodexAppServer"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"let mut attempts = 0;\nloop {\n    match server.run_turn(prompt).await {\n        Ok(r) => break Ok(r),\n        Err(e) if e.to_string().contains(\"超时\") && attempts < 1 => {\n            attempts += 1;\n            server = CodexAppServer::start(config.clone()).await?;\n        }\n        Err(e) => break Err(e),\n    }\n}","preventionTips":["Split long tasks into smaller turns under the 600s deadline","Keep the Codex CLI updated so turn-completion events are recognized","Monitor app-server stderr for hangs; restart on silence","Prevent system sleep during active turns"],"tags":["timeout","ipc","json-rpc","async"],"backgroundTag":"request-timeout","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}