RequestEntityTooLargeException aws resource_error ai_generated true

ClientError:调用 InvokeWithResponseStream 操作时发生错误 (RequestEntityTooLargeException):响应负载大小超过允许的最大负载大小 (6291556 字节)

ClientError: An error occurred (RequestEntityTooLargeException) when calling the InvokeWithResponseStream operation: Response payload size exceeded maximum allowed payload size (6291556 bytes)

ID: aws/lambda-invoke-response-stream-too-large

其他格式: JSON · Markdown 中文 · English
82%修复率
86%置信度
1证据数
2024-01-15首次发现

版本兼容性

版本状态引入弃用备注
Lambda 2015-03-31 active
AWS SDK for JavaScript 3.600.0 active
Node.js 20.x active

根因分析

Lambda 响应流式传输负载超过了 6 MB 的流式响应限制,导致调用失败。

English

Lambda response streaming payload exceeded the 6 MB limit for streamed responses, causing the invocation to fail.

generic

官方文档

https://docs.aws.amazon.com/lambda/latest/dg/invocation-response-streaming.html

解决方案

  1. 使用 Lambda 响应流式传输将响应拆分为多个块,每个块发送较小的负载,或在客户端使用分页来分部分请求数据。
  2. 将大响应存储在 S3 中,并向客户端返回预签名 URL,完全避免 Lambda 响应大小限制。

无效尝试

常见但无效的做法:

  1. Increase the Lambda function's timeout or memory. 90% 失败

    The error is about payload size, not execution duration or memory.

  2. Use synchronous Invoke instead of InvokeWithResponseStream. 70% 失败

    Synchronous Invoke has a 6 MB limit as well, and the error will persist.

  3. Compress the response payload with gzip. 60% 失败

    Lambda does not automatically decompress gzip; the client would need to handle it, and the limit applies to the raw payload before compression.