openai/codex · error · anyhow::Error
CancelSynchronousIo failed for runner
Error message
CancelSynchronousIo failed for runner {pipe_label} connect thread: {err} What it means
CancelSynchronousIo returned zero while attempting to cancel the runner connect thread's blocking named-pipe connect, and the failure code is not ERROR_NOT_FOUND (which would mean the thread already finished). This means the OS could not cancel the pending synchronous I/O for that thread, so the connect attempt state is unknown.
Solutions
- Treat ERROR_NOT_FOUND as success (thread already completed) — the code already does this
- Check that thread_handle is a valid, still-open handle to the connect thread
- Retry cancellation once after a short sleep in case the thread is transitioning between blocking calls
- If cancellation keeps failing, log the pipe label and error code and fail the connect operation rather than hanging
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:266 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/427bf1897d30a0ff.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:266
if let Some(connect_thread) = connect_thread.take() {
let _ = connect_thread.join();
}
result
}
Err(mpsc::RecvTimeoutError::Timeout) => {
if let Some(result) = try_take_completed_connect_result(
&mut connect_thread,
&connect_result_rx,
thread_handle,
&pipe_label,
)? {
result
} else {
let cancel_ok = unsafe { CancelSynchronousIo(thread_handle) };
if cancel_ok == 0 {
let err = unsafe { GetLastError() };
if err != ERROR_NOT_FOUND {
Err(anyhow::anyhow!(
"CancelSynchronousIo failed for runner {pipe_label} connect thread: {err}"
))
} else if let Some(result) = try_take_completed_connect_result(
&mut connect_thread,
&connect_result_rx,
thread_handle,
&pipe_label,
)? {
result
} else {
Err(anyhow::anyhow!(
"timed out after {}ms connecting runner {pipe_label}",
RUNNER_PIPE_CONNECT_TIMEOUT.as_millis()
))
}
} else {
// Do not join the helper thread on the timeout path. Parent-side cleanup will
// close the pipe handles, which lets the blocked connect unwind withoutView on GitHub (pinned to 339751715c)