openai/codex · error
WriteFile failed
Error message
WriteFile failed: {err} What it means
The raw WriteFile syscall on a child stdin/pipe HANDLE failed (returned 0) and GetLastError() supplied the Win32 error code interpolated as {err}. Common causes: the pipe's read end is closed (ERROR_BROKEN_PIPE / ERROR_NO_DATA) because the child exited, or an invalid handle after teardown; the error code is numeric, not symbolic.
Solutions
- Check that the pipe to the process is still open (the process may have exited) and inspect the inner Win32 error; retry the write.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs:227 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/9e084720e386321a.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs:227
fn write_all_handle(handle: HANDLE, mut bytes: &[u8]) -> Result<()> {
while !bytes.is_empty() {
let mut written = 0u32;
let ok = unsafe {
WriteFile(
handle,
bytes.as_ptr() as *const _,
bytes.len() as u32,
&mut written,
ptr::null_mut(),
)
};
if ok == 0 {
let err = unsafe { GetLastError() } as i32;
return Err(anyhow::anyhow!("WriteFile failed: {err}"));
}
if written == 0 {
anyhow::bail!("WriteFile returned success but wrote 0 bytes");
}
bytes = &bytes[written as usize..];
}
Ok(())
}View on GitHub (pinned to 339751715c)