openai/codex · error · anyhow::Error

expected spawn_ready from runner, got

Error message

expected spawn_ready from runner, got {other:?}

What it means

Protocol violation in read_spawn_ready: a complete frame arrived on the runner pipe, but its message variant is not the expected SpawnReady handshake. The unexpected Message variant is included in the error, indicating the runner spoke out of order or the streams are desynchronized.

Solutions

  1. Check which message variant arrived to infer the desynchronization cause
  2. Verify both sides use the same IPC_PROTOCOL_VERSION so message ordering matches
  3. Restart the runner and client so the handshake begins from a clean state
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:166 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/a1de9816cd5b231b. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:166

impl RunnerTransport {
    pub(crate) fn send_spawn_request(&mut self, request: SpawnRequest) -> Result<()> {
        let spawn_request = FramedMessage {
            version: IPC_PROTOCOL_VERSION,
            message: Message::SpawnRequest {
                payload: Box::new(request),
            },
        };
        write_frame(&mut self.pipe_write, &spawn_request)
    }

    pub(crate) fn read_spawn_ready(&mut self) -> Result<()> {
        wait_for_complete_frame(&self.pipe_read, RUNNER_SPAWN_READY_TIMEOUT)?;
        let msg = read_frame(&mut self.pipe_read)?
            .ok_or_else(|| anyhow::anyhow!("runner pipe closed before spawn_ready"))?;
        match msg.message {
            Message::SpawnReady { .. } => Ok(()),
            Message::Error { payload } => Err(RunnerStartupError::new(payload).into()),
            other => Err(anyhow::anyhow!(
                "expected spawn_ready from runner, got {other:?}"
            )),
        }
    }

    pub(crate) fn into_files(self) -> (File, File) {
        (self.pipe_write, self.pipe_read)
    }
}

fn try_take_completed_connect_result(
    connect_thread: &mut Option<thread::JoinHandle<()>>,
    connect_result_rx: &mpsc::Receiver<Result<()>>,
    thread_handle: HANDLE,
    pipe_label: &str,
) -> Result<Option<Result<()>>> {
    let thread_wait = unsafe { WaitForSingleObject(thread_handle, 0) };
    if thread_wait != WAIT_OBJECT_0 {

View on GitHub (pinned to 339751715c)