{"record":{"id":"d7b2bc689ded6bda","repo":"different-ai/openwork","slug":"agent-context-diagnostics-request-timed-out","errorCode":"agent_context_diagnostics_request_timed_out","errorMessage":"Agent context diagnostics request timed out.","messagePattern":"Agent context diagnostics request timed out\\.","errorType":"exception","errorClass":"AgentContextDiagnosticsTransportError","httpStatus":null,"severity":"error","filePath":"apps/app/src/app/lib/agent-context-diagnostics-transport.ts","lineNumber":76,"sourceCode":"    ) {\n      cancelUnlockedBody(response);\n      throw responseTooLargeError();\n    }\n  }\n\n  if (!response.body) return \"\";\n\n  const reader = response.body.getReader();\n  const chunks: Uint8Array[] = [];\n  let bytesRead = 0;\n  const cancelOnAbort = () => {\n    void reader.cancel().catch(() => undefined);\n  };\n  signal.addEventListener(\"abort\", cancelOnAbort, { once: true });\n\n  try {\n    while (true) {\n      if (signal.aborted) throw timeoutError();\n      const chunk = await reader.read();\n      if (chunk.done) break;\n      bytesRead += chunk.value.byteLength;\n      if (bytesRead > AGENT_CONTEXT_DIAGNOSTICS_RESPONSE_MAX_BYTES) {\n        void reader.cancel().catch(() => undefined);\n        throw responseTooLargeError();\n      }\n      chunks.push(chunk.value);\n    }\n  } catch (error) {\n    if (signal.aborted) throw timeoutError();\n    throw error;\n  } finally {\n    signal.removeEventListener(\"abort\", cancelOnAbort);\n    reader.releaseLock();\n  }\n\n  const bytes = new Uint8Array(bytesRead);","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/app/src/app/lib/agent-context-diagnostics-transport.ts#L58-L94","documentation":"readBoundedResponseText checks the AbortSignal before each chunk read of the diagnostics response body. If the signal is already aborted when a read iteration starts, it throws the AgentContextDiagnosticsTransportError with code agent_context_diagnostics_request_timed_out. The overall 30s deadline (AbortController in requestAgentContextDiagnosticsPayload) fires the abort that leads here.","triggerScenarios":"The diagnostics HTTP response body is being streamed and the 30s timeout (AGENT_CONTEXT_DIAGNOSTICS_REQUEST_TIMEOUT_MS) elapses mid-body; on the next loop iteration signal.aborted is true and the timeout error is thrown before attempting the read.","commonSituations":"Slow or hanging diagnostics endpoint that starts responding but trickles the body past the deadline; large responses on a slow network; server that sends headers then stalls the body.","solutions":["Investigate why the diagnostics endpoint is slow/stalling (server logs, network)","Reduce the diagnostics payload size so the body completes within 30s","Increase the caller-provided timeoutMs within the allowed max of 30000 ms if the endpoint legitimately needs longer","Retry the request once network/server load has settled"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const { payload } = await requestAgentContextDiagnosticsPayload({ fetchImpl, url, init });\n} catch (e) {\n  if (e instanceof AgentContextDiagnosticsTransportError && e.code === \"agent_context_diagnostics_request_timed_out\") {\n    // retry or show a timeout notice; the server took >30s to finish the body\n  } else throw e;\n}","preventionTips":["Keep diagnostics endpoints fast; precompute heavy data","Keep payload small so streaming finishes well inside 30s","Pass an explicit timeoutMs up to 30000 when the endpoint is known to be slower","Retry once on the timed_out code before failing the UX"],"tags":["timeout","network","streaming"],"backgroundTag":"request-timeout","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}