{"record":{"id":"cb0fdeee1292ca31","repo":"BigPizzaV3/CodexPlusPlus","slug":"codex-app-server-method","errorCode":null,"errorMessage":"Codex app-server {method} 请求超时","messagePattern":"Codex app-server (.+?) 请求超时","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/connect/app_server.rs","lineNumber":352,"sourceCode":"    async fn request(\n        &mut self,\n        method: &str,\n        params: Value,\n        timeout: Duration,\n    ) -> anyhow::Result<Value> {\n        let id = self.take_request_id();\n        self.write_json(&json!({\n            \"jsonrpc\": \"2.0\",\n            \"id\": id,\n            \"method\": method,\n            \"params\": params\n        }))\n        .await?;\n        let deadline = tokio::time::Instant::now() + timeout;\n        loop {\n            let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());\n            if remaining.is_zero() {\n                bail!(\"Codex app-server {method} 请求超时\");\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                continue;\n            }\n            if let Some(error) = rpc_error(&message) {\n                bail!(\"Codex app-server {method} 失败：{error}\");\n            }\n            return Ok(message.get(\"result\").cloned().unwrap_or(Value::Null));\n        }\n    }\n\n    async fn read_message(&mut self, timeout: Duration) -> anyhow::Result<Value> {\n        loop {","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/connect/app_server.rs#L334-L370","documentation":"The request() helper sends a JSON-RPC method to the Codex app-server and loops reading messages under the caller-supplied timeout (default REQUEST_TIMEOUT = 120s via initialize/prepare_thread). If the deadline expires before the matching response arrives, it throws this error naming the method, e.g. \"Codex app-server initialize 请求超时\".","triggerScenarios":"Calling initialize or prepare_thread (both call request) when the app-server never answers within the timeout: server slow to start, deadlocked, crashed without closing the pipe, or flood of server requests being rejected one by one.","commonSituations":"Codex CLI first-run initialization taking very long, antivirus scanning the binary, app-server hung on startup, system under heavy load, CLI version that never responds to the sent method.","solutions":["Retry; check the app-server process is alive and inspect its stderr tail","Ensure the Codex CLI is responsive on its own (run `codex --version`)","Update the Codex CLI — an unresponsive/old app-server build is a common cause","Increase timeouts at the call site if your environment legitimately needs more than 120s for initialize"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"let mut attempts = 0;\nloop {\n    match CodexAppServer::start(config.clone()).await {\n        Ok(s) => break Ok(s),\n        Err(e) if e.to_string().contains(\"请求超时\") && attempts < 1 => { attempts += 1; }\n        Err(e) => break Err(e),\n    }\n}","preventionTips":["Smoke-test the CLI with --version before start","Disable system sleep during initialize","Update the CLI if initialize is routinely slow","Keep request payloads (work_dir, options) simple and valid"],"tags":["timeout","json-rpc","ipc","startup"],"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"}