{"record":{"id":"0e549ed2586852ee","repo":"openai/codex","slug":"timed-out-waiting-for-pid-reservation-in-to-fin","errorCode":null,"errorMessage":"timed out waiting for pid reservation in {} to finish initializing","messagePattern":"timed out waiting for pid reservation in (.+?) to finish initializing","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/app-server-daemon/src/backend/pid.rs","lineNumber":297,"sourceCode":"            }\n\n            if self.record_is_active(&record).await? {\n                bail!(\"timed out waiting for pid-managed app server {pid} to stop\");\n            }\n        }\n    }\n\n    async fn wait_for_pid_start(&self) -> Result<Option<PidRecord>> {\n        let deadline = tokio::time::Instant::now() + START_TIMEOUT;\n        loop {\n            match self.read_pid_file_state().await? {\n                PidFileState::Missing => return Ok(None),\n                PidFileState::Running(record) => return Ok(Some(record)),\n                PidFileState::Starting if tokio::time::Instant::now() < deadline => {\n                    sleep(STOP_POLL_INTERVAL).await;\n                }\n                PidFileState::Starting => {\n                    bail!(\n                        \"timed out waiting for pid reservation in {} to finish initializing\",\n                        self.pid_file.display()\n                    );\n                }\n            }\n        }\n    }\n\n    async fn read_pid_file_state(&self) -> Result<PidFileState> {\n        let contents = match fs::read_to_string(&self.pid_file).await {\n            Ok(contents) => contents,\n            Err(err) if err.kind() == std::io::ErrorKind::NotFound => {\n                return if reservation_lock_is_active(&self.lock_file).await? {\n                    Ok(PidFileState::Starting)\n                } else {\n                    Ok(PidFileState::Missing)\n                };\n            }","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/app-server-daemon/src/backend/pid.rs#L279-L315","documentation":"wait_for_pid_start() polls the daemon pid file waiting for a reservation in state Starting to transition to Running within START_TIMEOUT. This error fires when the pid file still says Starting at the deadline — the app-server process that reserved the pid never finished initializing (crashed mid-startup without cleanup, or is hung), so no usable PidRecord can be returned.","triggerScenarios":"Thrown at codex-rs/app-server-daemon/src/backend/pid.rs:297 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after the stale reservation is reaped; the next stop/start cycle refreshes the pid file","Investigate why the starting app-server process hangs or dies before publishing its Running state","Consider reaping stale Starting records after a shorter startup deadline"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}