diegosouzapw/OmniRoute · error
[codex] closeUpstream: socket close race ignored
Error message
[codex] closeUpstream: socket close race ignored
What it means
closeUpstream tried ws.close(1000, reason) on the upstream WebSocket but the socket was already closed/closing (a close race between the shutdown path and the socket lifecycle). Intentionally ignored — the socket is going away regardless; this is a benign race guard, not a real failure.
Solutions
- No action needed — the race is harmless by design
- If noisy, correlate with abort/finish ordering to confirm normal teardown
- Ignore unless accompanied by stream truncation symptoms
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at open-sse/executors/codex.ts:908 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/16bc410e0b9dbbc7.
Report an issue: GitHub.
Appendix: source
Thrown at open-sse/executors/codex.ts:908
if (!websocketFn) {
return {
response: codexWebSocketUnavailableResponse(),
url,
headers,
transformedBody,
};
}
const encoder = new TextEncoder();
let closed = false;
let ws: WreqWebSocket | null = null;
let streamController: ReadableStreamDefaultController<Uint8Array> | null = null;
const closeUpstream = (reason: string) => {
try {
ws?.close(1000, reason);
} catch {
console.warn("[codex] closeUpstream: socket close race ignored");
// ignore close races
}
};
let abortHandler: (() => void) | null = null;
const removeAbortListener = () => {
if (!abortHandler) return;
nextInput.signal?.removeEventListener("abort", abortHandler);
abortHandler = null;
};
const finishStream = ({
reason,
emitDone = true,
closeController = true,
closeSocket = true,
}: {
reason: string;View on GitHub (pinned to a179ffed5b)