{"record":{"id":"12767024f1dd0904","repo":"vercel/ai","slug":"xai-video-status-response-exceeded-max-pending-b","errorCode":null,"errorMessage":"xAI video status response exceeded ${MAX_PENDING_BODY_BYTES} bytes","messagePattern":"xAI video status response exceeded (.+?) bytes","errorType":"exception","errorClass":"APICallError","httpStatus":null,"severity":"error","filePath":"packages/xai/src/xai-video-model.ts","lineNumber":726,"sourceCode":"  url,\n  requestBodyValues,\n}: Parameters<ResponseHandler<unknown>>[0]): Promise<string> {\n  if (response.body == null) {\n    return '';\n  }\n\n  const reader = response.body.getReader();\n  const chunks: Uint8Array[] = [];\n  let totalBytes = 0;\n\n  try {\n    while (true) {\n      const { done, value } = await reader.read();\n      if (done) break;\n\n      totalBytes += value.length;\n      if (totalBytes > MAX_PENDING_BODY_BYTES) {\n        throw new APICallError({\n          message: `xAI video status response exceeded ${MAX_PENDING_BODY_BYTES} bytes`,\n          url,\n          requestBodyValues,\n          statusCode: response.status,\n          responseHeaders: extractResponseHeaders(response),\n        });\n      }\n\n      chunks.push(value);\n    }\n  } finally {\n    reader.releaseLock();\n  }\n\n  const merged = new Uint8Array(totalBytes);\n  let offset = 0;\n  for (const chunk of chunks) {\n    merged.set(chunk, offset);","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/xai/src/xai-video-model.ts#L708-L744","documentation":"readPendingBody in the xAI video model reads the polling/status response body with a hard cap of MAX_PENDING_BODY_BYTES. While streaming the status body, if the accumulated bytes exceed the cap, an APICallError is thrown to prevent unbounded memory consumption from a misbehaving or unexpected response. This is a defensive guard, not a normal operational state.","triggerScenarios":"The xAI video status endpoint returns an unexpectedly huge body (e.g. server misconfiguration returning an HTML error page, a proxy dumping a large payload, or an API contract change inflating the status payload).","commonSituations":"Gateway/captive-portal HTML error pages; debugging endpoints echoing large payloads; misconfigured mock servers in tests; extremely long-running videos if the status payload embeds verbose data.","solutions":["Inspect the actual status URL response (curl it) to see what oversized payload is being returned.","Check proxies/gateways for injected error pages and fix the upstream xAI API reachability.","Retry the status poll; transient server issues often resolve.","Update @ai-sdk/xai; if legitimate status payloads have grown, a newer version may raise or handle the limit."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await pollVideoStatus(url);\n} catch (e) {\n  if (APICallError.isInstance(e) && e.message.includes('exceeded') && e.message.includes('bytes')) {\n    // treat as transient/infra issue: log URL + status, retry poll after backoff\n  } else throw e;\n}","preventionTips":["Ensure the xAI API base URL is reachable directly (no HTML error pages from gateways).","Use the provider's configured fetch without body-logging middlewares in production.","Monitor for xAI API contract changes if status payloads grow; keep the package updated.","In tests, use fixtures sized like real status payloads rather than huge mock dumps."],"tags":["xai","video-generation","response-size","network","polling"],"backgroundTag":"response-body-too-large","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}