# 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`
- **Domain:** aws
- **Category:** resource_error
- **Error Code:** `RequestEntityTooLargeException`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

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

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Lambda 2015-03-31 | active | — | — |
| AWS SDK for JavaScript 3.600.0 | active | — | — |
| Node.js 20.x | active | — | — |

## Workarounds

1. **Split the response into multiple chunks using Lambda response streaming, sending smaller payloads per chunk, or use pagination in the client to request data in parts.** (82% success)
   ```
   Split the response into multiple chunks using Lambda response streaming, sending smaller payloads per chunk, or use pagination in the client to request data in parts.
   ```
2. **Store the large response in S3 and return a pre-signed URL to the client, avoiding the Lambda response size limit altogether.** (90% success)
   ```
   Store the large response in S3 and return a pre-signed URL to the client, avoiding the Lambda response size limit altogether.
   ```

## Dead Ends

- **Increase the Lambda function's timeout or memory.** — The error is about payload size, not execution duration or memory. (90% fail)
- **Use synchronous Invoke instead of InvokeWithResponseStream.** — Synchronous Invoke has a 6 MB limit as well, and the error will persist. (70% fail)
- **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% fail)
