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

- **ID:** `aws/lambda-invoke-response-stream-too-large`
- **领域:** aws
- **类别:** resource_error
- **错误码:** `RequestEntityTooLargeException`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

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

## 版本兼容性

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

## 解决方案

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

## 无效尝试

- **Increase the Lambda function's timeout or memory.** — The error is about payload size, not execution duration or memory. (90% 失败率)
- **Use synchronous Invoke instead of InvokeWithResponseStream.** — Synchronous Invoke has a 6 MB limit as well, and the error will persist. (70% 失败率)
- **Compress the response payload with gzip.** — Lambda does not automatically decompress gzip; the client would need to handle it, and the limit applies to the raw payload before compression. (60% 失败率)
