musistudio/claude-code-router · error · Error
Timed out waiting for ChatGPT response: + requestId
Error message
Timed out waiting for ChatGPT response: + requestId
What it means
Polling helper that waits (100ms loop) for a response keyed by requestId to appear in a Map of resolved ChatGPT request replies; it throws when the deadline elapses. It means the upstream ChatGPT-backed request never produced (or never matched) a response within the timeout window.
Source
Thrown at packages/core/src/agents/codex/cli-middleware-runtime.ts:4908
if (toolUseId) response.toolUseID = toolUseId;
return { type: "control_response", response: { subtype: "success", request_id: requestId, response } };
}
function claudeControlElicitationResponse(requestId, value) {
return { type: "control_response", response: { subtype: "success", request_id: requestId, response: value || {} } };
}
async function waitForAppResponse(map, requestId, timeoutMs) {
const started = Date.now();
while (Date.now() - started < timeoutMs) {
if (map.has(requestId)) {
const value = map.get(requestId);
map.delete(requestId);
return value;
}
await sleep(100);
}
throw new Error("Timed out waiting for ChatGPT response: " + requestId);
}
function permissionResponseAllows(value) {
if (!value) return false;
if (value.approved === true || value.allow === true || value.allowed === true || value.decision === "allow") return true;
if (value.approved === false || value.allow === false || value.allowed === false || value.decision === "deny") return false;
if (typeof value === "boolean") return value;
return Boolean(value);
}
function writeResponse(id, result) {
writeRaw({ id, result });
}
function writeError(id, code, message) {
writeRaw({ id, error: { code, message } });
}
View on GitHub (pinned to 99f24806c6)
Solutions
- Retry the request — transient backend slowness is the most common cause
- Increase the response timeout constant if your workload routinely exceeds it
- Verify network/proxy connectivity to the ChatGPT backend and that the session is still alive
- Log the requestId alongside responses to detect correlation (key mismatch) bugs
Example fix
// before const value = await waitForChatGptResponse(map, requestId); // throws on timeout // after const value = await waitForChatGptResponse(map, requestId) .catch(() => retryWithBackoff(() => issueChatGptRequest(params), 3));
Defensive patterns
Strategy: retry
Validate before calling
null
Type guard
null
Try / catch
try { return await waitForChatGptResponse(map, requestId); } catch (e) { if (/Timed out waiting for ChatGPT response/.test(String(e))) { return await withBackoff(() => issueChatGptRequest(params), 3); } throw e; } Prevention
- Retry once on timeout before surfacing the error to users
- Raise the timeout for long-generation workloads
- Log requestId on both request and response paths to catch correlation bugs
When it happens
Trigger: Awaiting a ChatGPT response whose reply never lands in the map: upstream network stall, requestId mismatch/correlation bug, response arrived after the timeout expired, or the backing session died before responding.
Common situations: Slow ChatGPT backend exceeding the fixed timeout; proxy/firewall dropping long-lived connections; requestId reused or malformed so the response is stored under a different key; Codex session disconnected mid-request.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Codex App DevTools port was not available${lastError ? `: ${
- Codex App CDP page target was not available${lastError ? `:
- Grok CLI OAuth token refresh timed out after ${timeoutMs}ms.
- Grok CLI OIDC discovery timed out after ${timeoutMs}ms.
- Kimi CLI OAuth token refresh timed out after ${kimiOauthRefr
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/81a50519ed6418f6.
Report an issue: GitHub.