openai/codex · error · anyhow::Error
runner connect thread exited before reporting its result
Error message
runner {pipe_label} connect thread exited before reporting its result What it means
Sentinel inconsistency error from try_take_completed_connect_result: WaitForSingleObject signaled the connect thread finished, but the mpsc receiver for its result returned Err (channel closed) after joining. The thread exited without sending its result, which should be impossible — the channel or thread bookkeeping is broken.
Solutions
- Treat as an internal invariant bug and report the pipe label for diagnosis
- Re-run the spawn attempt; transient thread/teardown races may clear on a fresh connect
- Check for panics in the connect thread that could abort it before it publishes its result
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:193 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/2d2ea1f8b6014898.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:193
}
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 {
return Ok(None);
}
if let Some(connect_thread) = connect_thread.take() {
let _ = connect_thread.join();
}
let result = connect_result_rx.recv().map_err(|_| {
anyhow::anyhow!("runner {pipe_label} connect thread exited before reporting its result")
})?;
Ok(Some(result))
}
fn connect_pipe_with_timeout(
h_pipe: HANDLE,
expected_runner_pid: u32,
pipe_label: &str,
) -> Result<()> {
let pipe_label = pipe_label.to_string();
let pipe_label_for_thread = pipe_label.clone();
let (thread_handle_tx, thread_handle_rx) = mpsc::sync_channel(1);
let (connect_result_tx, connect_result_rx) = mpsc::sync_channel(1);
let mut connect_thread = Some(
thread::Builder::new()
.name(format!("codex-runner-connect-{pipe_label}"))
.spawn(move || {
let current_process = unsafe { GetCurrentProcess() };View on GitHub (pinned to 339751715c)