question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

413 response body too large error could be more clear

See original GitHub issue

When 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:

CleanShot 2022-06-15 at 20 23 52@2x

And the corresponding function log error:

CleanShot 2022-06-15 at 20 24 05@2x

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:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
leerobcommented, Jun 20, 2022

It’s likely due to the size of dehydratedStateData returned from the server - can you try only returning the data inside there you need?

0reactions
brian-enkorcommented, Jun 20, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found