{"record":{"id":"4b8c2c9031e13646","repo":"openai/codex","slug":"peeknamedpipe-failed-while-waiting-for-spawn-ready","errorCode":null,"errorMessage":"PeekNamedPipe failed while waiting for spawn_ready: {err}","messagePattern":"PeekNamedPipe failed while waiting for spawn_ready: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs","lineNumber":463,"sourceCode":"    let deadline = Instant::now() + timeout;\n    let mut len_buf = [0u8; 4];\n\n    loop {\n        let mut bytes_read = 0u32;\n        let mut total_available = 0u32;\n        let ok = unsafe {\n            PeekNamedPipe(\n                handle,\n                len_buf.as_mut_ptr() as *mut c_void,\n                len_buf.len() as u32,\n                &mut bytes_read,\n                &mut total_available,\n                ptr::null_mut(),\n            )\n        };\n        if ok == 0 {\n            let err = unsafe { GetLastError() } as i32;\n            return Err(anyhow::anyhow!(\n                \"PeekNamedPipe failed while waiting for spawn_ready: {err}\"\n            ));\n        }\n\n        if bytes_read == len_buf.len() as u32 {\n            let frame_len = u32::from_le_bytes(len_buf) as usize;\n            let total_len = frame_len\n                .checked_add(len_buf.len())\n                .ok_or_else(|| anyhow::anyhow!(\"runner frame length overflow\"))?;\n            if total_available as usize >= total_len {\n                return Ok(());\n            }\n        }\n\n        if Instant::now() >= deadline {\n            return Err(anyhow::anyhow!(\n                \"timed out after {}ms waiting for runner spawn_ready\",\n                timeout.as_millis()","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs#L445-L481","documentation":"PeekNamedPipe returned zero while polling the runner pipe for the 4-byte spawn_ready frame header, so the pipe state could not be inspected. Typically means the pipe is broken/closed (ERROR_BROKEN_PIPE) or the handle is invalid, and the wait loop for spawn_ready must abort.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:463 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the returned GetLastError code; ERROR_BROKEN_PIPE means the runner exited before sending spawn_ready — check runner crash logs","Verify the pipe read handle was not closed prematurely","If the runner died, restart it and re-establish the pipe connection"],"exampleFix":null,"handlingStrategy":"try-catch","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"}