{"record":{"id":"0ac63af2de427274","repo":"vercel/ai","slug":"incomplete-amazon-bedrock-event-stream-frame-bu","errorCode":null,"errorMessage":"Incomplete Amazon Bedrock event-stream frame: ${buffer.length} buffered bytes remain at end of stream.","messagePattern":"Incomplete Amazon Bedrock event-stream frame: (.+?) buffered bytes remain at end of stream\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/amazon-bedrock/src/amazon-bedrock-event-stream-decoder.ts","lineNumber":63,"sourceCode":"\n          const messageType = decoded.headers[':message-type']?.value as string;\n          const eventType = decoded.headers[':event-type']?.value as\n            | string\n            | undefined;\n          const exceptionType = decoded.headers[':exception-type']?.value as\n            | string\n            | undefined;\n          const data = textDecoder.decode(decoded.body);\n\n          await processEvent(\n            { messageType, eventType, exceptionType, data },\n            controller,\n          );\n        }\n      },\n      flush() {\n        if (buffer.length > 0) {\n          throw new Error(\n            `Incomplete Amazon Bedrock event-stream frame: ${buffer.length} buffered bytes remain at end of stream.`,\n          );\n        }\n      },\n    }),\n  );\n}\n","sourceCodeStart":45,"sourceCodeEnd":71,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/amazon-bedrock-event-stream-decoder.ts#L45-L71","documentation":"Bedrock's event-stream protocol frames carry explicit total lengths; the decoder buffers bytes until a complete frame arrives. If the stream ends while bytes are still buffered, the frame was truncated, so flush() throws rather than parsing a partial event. This indicates a broken/interrupted connection or a malformed upstream stream.","triggerScenarios":"The HTTP response body from Bedrock's InvokeModelWithResponseStream ends mid-frame — network interruption, proxy/load-balancer timeout cutting the connection, or an intermediary that altered chunk boundaries.","commonSituations":"Long-running streams killed by an ALB/API gateway idle timeout; streaming through a corporate proxy that buffers and truncates; mobile/unstable networks dropping the connection mid-response.","solutions":["Retry the request — transient network truncation is usually resolved by re-invoking the model","Check proxies/load balancers for idle/read timeouts and raise them for streaming responses","Ensure you are not consuming response.body through another transformation that drops trailing chunks","Update @ai-sdk/amazon-bedrock; if persistent, capture the request ID from response headers and report to AWS support"],"exampleFix":"// before\nconst result = await streamText({ model, prompt }); // one shot, no retry\n// after\nconst result = await retry(\n  () => streamText({ model, prompt }),\n  { attempts: 3, on: /Incomplete Amazon Bedrock event-stream frame/ }\n);","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await streamText({ model, prompt });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Incomplete Amazon Bedrock event-stream frame')) {\n    return await streamText({ model, prompt }); // retry with backoff\n  }\n  throw e;\n}","preventionTips":["Raise proxy/LB idle timeouts for streaming routes","Avoid intermediary transformations of response.body","Use resumable streams for long generations"],"tags":["streaming","bedrock","network","truncated-response"],"backgroundTag":"truncated-stream","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}