{"record":{"id":"427bf1897d30a0ff","repo":"openai/codex","slug":"cancelsynchronousio-failed-for-runner-pipe-label","errorCode":null,"errorMessage":"CancelSynchronousIo failed for runner {pipe_label} connect thread: {err}","messagePattern":"CancelSynchronousIo failed for runner (.+?) connect thread: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs","lineNumber":266,"sourceCode":"            if let Some(connect_thread) = connect_thread.take() {\n                let _ = connect_thread.join();\n            }\n            result\n        }\n        Err(mpsc::RecvTimeoutError::Timeout) => {\n            if let Some(result) = try_take_completed_connect_result(\n                &mut connect_thread,\n                &connect_result_rx,\n                thread_handle,\n                &pipe_label,\n            )? {\n                result\n            } else {\n                let cancel_ok = unsafe { CancelSynchronousIo(thread_handle) };\n                if cancel_ok == 0 {\n                    let err = unsafe { GetLastError() };\n                    if err != ERROR_NOT_FOUND {\n                        Err(anyhow::anyhow!(\n                            \"CancelSynchronousIo failed for runner {pipe_label} connect thread: {err}\"\n                        ))\n                    } else if let Some(result) = try_take_completed_connect_result(\n                        &mut connect_thread,\n                        &connect_result_rx,\n                        thread_handle,\n                        &pipe_label,\n                    )? {\n                        result\n                    } else {\n                        Err(anyhow::anyhow!(\n                            \"timed out after {}ms connecting runner {pipe_label}\",\n                            RUNNER_PIPE_CONNECT_TIMEOUT.as_millis()\n                        ))\n                    }\n                } else {\n                    // Do not join the helper thread on the timeout path. Parent-side cleanup will\n                    // close the pipe handles, which lets the blocked connect unwind without","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs#L248-L284","documentation":"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.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/elevated/runner_client.rs:266 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}