openai/codex · error
WriteFile returned success but wrote 0 bytes
Error message
WriteFile returned success but wrote 0 bytes
What it means
Error "WriteFile returned success but wrote 0 bytes" thrown in openai/codex.
Source
Thrown at codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs:230
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(())
}
#[allow(clippy::too_many_arguments)]
fn finalize_exit(
exit_tx: oneshot::Sender<i32>,
process_handle: Arc<StdMutex<Option<HANDLE>>>,
thread_handle: HANDLE,
output_join: std::thread::JoinHandle<()>,
logs_base_dir: Option<&Path>,
command: Vec<String>,
) {
let exit_code = {
let mut raw_exit = 1u32;
if let Ok(guard) = process_handle.lock()View on GitHub (pinned to 339751715c)
Solutions
- Retry the write; a zero-byte successful write usually means the pipe buffer is full, so ensure the reader side is draining.
When it happens
Trigger: Thrown at codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs:230 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/1263f3614095bbf6.
Report an issue: GitHub.