{"record":{"id":"81a50519ed6418f6","repo":"musistudio/claude-code-router","slug":"timed-out-waiting-for-chatgpt-response-request","errorCode":null,"errorMessage":"Timed out waiting for ChatGPT response:  + requestId","messagePattern":"Timed out waiting for ChatGPT response:  \\+ requestId","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/codex/cli-middleware-runtime.ts","lineNumber":4908,"sourceCode":"  if (toolUseId) response.toolUseID = toolUseId;\n  return { type: \"control_response\", response: { subtype: \"success\", request_id: requestId, response } };\n}\n\nfunction claudeControlElicitationResponse(requestId, value) {\n  return { type: \"control_response\", response: { subtype: \"success\", request_id: requestId, response: value || {} } };\n}\n\nasync function waitForAppResponse(map, requestId, timeoutMs) {\n  const started = Date.now();\n  while (Date.now() - started < timeoutMs) {\n    if (map.has(requestId)) {\n      const value = map.get(requestId);\n      map.delete(requestId);\n      return value;\n    }\n    await sleep(100);\n  }\n  throw new Error(\"Timed out waiting for ChatGPT response: \" + requestId);\n}\n\nfunction permissionResponseAllows(value) {\n  if (!value) return false;\n  if (value.approved === true || value.allow === true || value.allowed === true || value.decision === \"allow\") return true;\n  if (value.approved === false || value.allow === false || value.allowed === false || value.decision === \"deny\") return false;\n  if (typeof value === \"boolean\") return value;\n  return Boolean(value);\n}\n\nfunction writeResponse(id, result) {\n  writeRaw({ id, result });\n}\n\nfunction writeError(id, code, message) {\n  writeRaw({ id, error: { code, message } });\n}\n","sourceCodeStart":4890,"sourceCodeEnd":4926,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/agents/codex/cli-middleware-runtime.ts#L4890-L4926","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst value = await waitForChatGptResponse(map, requestId); // throws on timeout\n\n// after\nconst value = await waitForChatGptResponse(map, requestId)\n  .catch(() => retryWithBackoff(() => issueChatGptRequest(params), 3));","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"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; }","preventionTips":["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"],"tags":["timeout","polling","request-correlation","upstream"],"backgroundTag":"upstream-response-timeout","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}