{"record":{"id":"730b10b46838f3a3","repo":"stablyai/orca","slug":"relay-director-resolve-response-too-large","errorCode":null,"errorMessage":"relay director resolve response too large","messagePattern":"relay director resolve response too large","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mobile/src/transport/mobile-relay-resume-director.ts","lineNumber":39,"sourceCode":"  const timer = setTimeout(() => controller.abort(), args.timeoutMs ?? 5000)\n  try {\n    const url = new URL('/v1/resolve', args.relay.directorUrl)\n    const response = await (args.fetchImpl ?? fetch)(url.toString(), {\n      method: 'POST',\n      headers: { 'content-type': 'application/json' },\n      body: JSON.stringify({\n        v: 1,\n        relayHostId: args.relay.relayHostId,\n        resumeToken: args.resumeToken\n      }),\n      signal: controller.signal\n    })\n    if (!response.ok) {\n      throw new Error(`relay director resolve failed (${response.status})`)\n    }\n    const declaredLength = Number(response.headers.get('content-length') ?? 0)\n    if (declaredLength > MAX_RESPONSE_BYTES) {\n      throw new Error('relay director resolve response too large')\n    }\n    const raw = await response.text()\n    if (new TextEncoder().encode(raw).byteLength > MAX_RESPONSE_BYTES) {\n      throw new Error('relay director resolve response too large')\n    }\n    const resolved = ResolveResponseSchema.parse(JSON.parse(raw) as unknown)\n    return {\n      ...args.relay,\n      cellUrl: resolved.cellUrl,\n      assignmentEpoch: resolved.assignmentEpoch\n    }\n  } finally {\n    clearTimeout(timer)\n  }\n}\n\nfunction isCanonicalHttpsOrigin(value: string): boolean {\n  try {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/transport/mobile-relay-resume-director.ts#L21-L57","documentation":"Thrown in resolveMobileRelayEndpoint when the response's declared content-length header exceeds MAX_RESPONSE_BYTES (16 KiB). The body is rejected before reading to prevent a memory blowup from a hostile or buggy director that honestly reports a huge length.","triggerScenarios":"The director returned a body whose declared content-length is over 16 KiB; a misconfigured/proxied endpoint streaming a large payload with an honest header.","commonSituations":"directorUrl pointing at a generic web server returning a large page; director bug concatenating responses; a proxy fronting the director with a large error payload.","solutions":["Verify relay.directorUrl points at the real relay director, not a generic server.","Treat the trip as a protocol anomaly; do not raise MAX_RESPONSE_BYTES to work around it.","Re-resolve from a known-good director URL."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const endpoint = await resolveMobileRelayEndpoint(args)\n} catch (error) {\n  if (error instanceof Error && error.message === 'relay director resolve response too large') {\n    // verify directorUrl points at the real director; do not raise the cap\n  }\n}","preventionTips":["Confirm relay.directorUrl targets the real relay director, not a generic web server.","Treat the size cap as a security boundary; never raise MAX_RESPONSE_BYTES to work around it.","Probe the director with a known-good resume token in staging to confirm small responses."],"tags":["relay","network","http","security","resume"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}