openai/codex · error · anyhow::Error

failed to create psuedo console: HRESULT

Error message

failed to create psuedo console: HRESULT {result}

What it means

CreatePseudoConsole returned an HRESULT other than S_OK while creating the ConPTY instance for the requested size and pipe pair. The message embeds the raw HRESULT; common causes are resource exhaustion or an OS too old to support pseudoconsoles.

Solutions

  1. Retry after freeing terminal resources on the machine
  2. Verify the OS supports CreatePseudoConsole (Windows 10 1809+)
  3. Fall back to a non-ConPTY execution path if available
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/utils/pty/src/win/psuedocon.rs:143 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/2ea7eb26ff814903. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/utils/pty/src/win/psuedocon.rs:143

}

impl PsuedoCon {
    pub fn raw_handle(&self) -> HPCON {
        self.con
    }

    pub fn new(size: COORD, input: FileDescriptor, output: FileDescriptor) -> Result<Self, Error> {
        let mut con: HPCON = INVALID_HANDLE_VALUE;
        let result = unsafe {
            (CONPTY.CreatePseudoConsole)(
                size,
                input.as_raw_handle() as _,
                output.as_raw_handle() as _,
                PSEUDOCONSOLE_RESIZE_QUIRK,
                &mut con,
            )
        };
        ensure!(
            result == S_OK,
            "failed to create psuedo console: HRESULT {result}"
        );
        Ok(Self {
            con,
            _input: input,
            _output: output,
        })
    }

    pub fn resize(&self, size: COORD) -> Result<(), Error> {
        let result = unsafe { (CONPTY.ResizePseudoConsole)(self.con, size) };
        ensure!(
            result == S_OK,
            "failed to resize console to {}x{}: HRESULT: {}",
            size.X,
            size.Y,
            result

View on GitHub (pinned to 339751715c)