{"record":{"id":"fed55ad35cacf2e3","repo":"BigPizzaV3/CodexPlusPlus","slug":"method","errorCode":null,"errorMessage":"{method} 超时","messagePattern":"\\{method\\} 超时","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"tools/codex-wechat/codex_wechat.py","lineNumber":457,"sourceCode":"    def _request(self, method: str, params: Any, timeout: int | None = None) -> dict[str, Any]:\n        req_id = self.next_id\n        self.next_id += 1\n        self._send({\"id\": req_id, \"method\": method, \"params\": params})\n\n        deadline = time.time() + (timeout or self.cfg.codex.timeout_seconds)\n        while time.time() < deadline:\n            try:\n                msg = self.messages.get(timeout=0.5)\n            except queue.Empty:\n                if self.proc and self.proc.poll() is not None:\n                    raise RuntimeError(f\"app-server 已退出，退出码 {self.proc.returncode}\")\n                continue\n            if msg.get(\"id\") == req_id:\n                if \"error\" in msg:\n                    raise RuntimeError(f\"{method} 失败：{msg['error']}\")\n                return msg.get(\"result\") or {}\n            # 其它通知留给当前请求外的事件循环自然丢弃。\n        raise TimeoutError(f\"{method} 超时\")\n\n    def _ensure_thread(self, user_id: str) -> str:\n        thread_id = self.threads.get(user_id)\n        if thread_id:\n            return thread_id\n\n        params: dict[str, Any] = {\n            \"cwd\": self.cfg.codex.workspace,\n            \"approvalPolicy\": self.cfg.codex.approval_policy,\n            \"sandbox\": self.cfg.codex.sandbox,\n            \"ephemeral\": True,\n            \"baseInstructions\": \"你是运行在微信里的 Codex 助手。全程中文，只把最终答复发给微信用户。\",\n        }\n        if self.cfg.codex.model:\n            params[\"model\"] = self.cfg.codex.model\n        result = self._request(\"thread/start\", params, timeout=60)\n        thread_id = result[\"thread\"][\"id\"]\n        self.threads[user_id] = thread_id","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/tools/codex-wechat/codex_wechat.py#L439-L475","documentation":"_request gives up when time exceeds the deadline (timeout seconds from config, or the explicit timeout used by initialize) without receiving the matching response and while the process is still alive. The app-server accepted the request but never answered in time.","triggerScenarios":"Thrown at tools/codex-wechat/codex_wechat.py:457 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase codex.timeout_seconds in the config if turns legitimately take long.","Check whether the app-server is stuck (CPU/idle) and restart it; inspect reader-thread logs for dropped notifications.","For initialize keep the 20s timeout but verify the binary starts quickly; for long turns use the turn-level timeout rather than a short one."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}