413 response body too large error could be more clear
See original GitHub issueWhen I deploy a function that has a large response body (greater than 5mb
):
import { readFileSync } from 'fs';
import path from 'path';
export default function handler(_, res) {
const file = path.join(process.cwd(), 'large.mp3');
const stringified = readFileSync(file, 'utf8');
res.setHeader('Content-Type', 'application/json');
return res.end(stringified);
}
I see a 500 error:

And the corresponding function log error:

This message:
LAMBDA_RUNTIME Failed to post handler success response. Http response code: 413.
Could more clearly state the reason it failed was due to the function response body size.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Fixing 413 Request Entity Too Large Errors
A 413 Request Entity Too Large error occurs when a request made from a client is too large to be processed by the...
Read more >How to Solve the "413 Request Entity Too Large" Error
“Too Large”: This is straightforward: the entity is bigger than the server is willing or able to serve. In fact, this error has...
Read more >413 Payload Too Large - HTTP - MDN Web Docs
The HTTP 413 Payload Too Large response status code indicates that the request entity is larger than limits defined by server; ...
Read more >How to avoid Request Entity Too Large 413 error
To fix this, you need to increase the value of the client_max_body_size directive. This directive defines the maximum amount of data Nginx will...
Read more >How to Fix the 413 Request Entity Too large Error in ...
In instances where you get an immediate 413 response and you are certain the PHP file upload limits are set appropriately, check the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s likely due to the size of
dehydratedStateData
returned from the server - can you try only returning the data inside there you need?Yes, actually looking into it, we figured it must have been due to the size of data returned from the server. We tried fetching data from the client-side without
getStaticProps
and it seems to work now!This issue was hard to resolve due to ambiguous error message I guess… sometimes we were looking into wrong places