openai/codex · error

CreateFileW failed for pipe

Error message

CreateFileW failed for pipe {name}: {err}

What it means

Fires in open_pipe when CreateFileW returns INVALID_HANDLE_VALUE while opening a named pipe created by the parent process (stdin/stdout/stderr transport). The error includes the pipe name and the GetLastError code; common causes are the pipe not existing yet, or access denied.

Solutions

  1. Ensure the parent created the pipe before the runner opens it (race/synchronization check)
  2. Verify the pipe name matches exactly, including the \\.\pipe\ prefix
  3. Check the GetLastError code (ERROR_FILE_NOT_FOUND, ERROR_ACCESS_DENIED, ERROR_PIPE_BUSY) for the cause
  4. Confirm the requested access mask matches the pipe's creation mode
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/bin/command_runner/win.rs:146 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/54d5ddaebe7145d3. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/windows-sandbox-rs/src/bin/command_runner/win.rs:146

}

/// Open a named pipe created by the parent process.
fn open_pipe(name: &str, access: u32) -> Result<HANDLE> {
    let path = to_wide(name);
    let handle = unsafe {
        CreateFileW(
            path.as_ptr(),
            access,
            0,
            std::ptr::null_mut(),
            OPEN_EXISTING,
            0,
            0,
        )
    };
    if handle == windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE {
        let err = unsafe { GetLastError() };
        return Err(anyhow::anyhow!("CreateFileW failed for pipe {name}: {err}"));
    }
    Ok(handle)
}

/// Send an error frame back to the parent process.
fn send_error(
    writer: &Arc<StdMutex<File>>,
    stage: ErrorStage,
    windows_error_code: Option<u32>,
    message: String,
) -> Result<()> {
    let msg = FramedMessage {
        version: IPC_PROTOCOL_VERSION,
        message: Message::Error {
            payload: ErrorPayload {
                message,
                stage,
                windows_error_code,

View on GitHub (pinned to 339751715c)