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.

add option to increase max file size supported by body-parser

See original GitHub issue

Middleware error

PayloadTooLargeError: request entity too large at readStream

The transferred entity is 42Mb, so how could I increase amount of transferred data via lws config?

Error message: Middleware error PayloadTooLargeError: request entity too large at readStream (/usr/local/lib/node_modules/local-web-server/node_modules/raw-body/index.js:155:17) at executor (/usr/local/lib/node_modules/local-web-server/node_modules/raw-body/index.js:112:5) at new Promise (<anonymous>) at getRawBody (/usr/local/lib/node_modules/local-web-server/node_modules/raw-body/index.js:111:10) at /usr/local/lib/node_modules/local-web-server/node_modules/co-body/lib/json.js:41:14 at process._tickCallback (internal/process/next_tick.js:68:7)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
misha-panyushkincommented, Sep 4, 2019

@75lb option for increasing size will be great!

P.S. It will be good to have an exclude flag for stack middleware also.

1reaction
75lbcommented, Sep 3, 2019

Try omitting lws-body-parser from the stack…

if you run this command you’ll see the default middleware stack (the list of middleware plugins that are active by default):

$ ws --default-stack
[
  'lws-basic-auth',
  'lws-body-parser',
  'lws-request-monitor',
  'lws-log',
  'lws-cors',
  'lws-json',
  'lws-compress',
  'lws-rewrite',
  'lws-blacklist',
  'lws-conditional-get',
  'lws-mime',
  'lws-range',
  'lws-spa',
  'lws-static',
  'lws-index'
]

To omit lws-body-parser (which i suspect is causing the issue) from the middleware stack, run this command (i skipped the lws- prefix from each plugin name - it is optional):

$ ws --stack basic-auth request-monitor log cors json compress rewrite blacklist conditional-get mime range spa static index

Let me know if that fixes the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change max size for body-parser/express?
You can use this with Express 4 to limit request body size/Upload file size, instead of express.json() and express.urlencoded(), ...
Read more >
Increasing max file size - Google Groups
What is the proper way to increase the maximum file size allowed for file uploads? I'm currently seeing this result using the loopback-component-storage ......
Read more >
Multer: Easily upload files with Node.js and Express
Building an app with Multer support; Creating our frontend; Install and ... First, create a folder called file-upload-example , then create ...
Read more >
body-parser-xml - npm
Adds XML parsing to the body-parser library, so you can convert incoming XML data into a ... limit. Controls the maximum request body...
Read more >
Express body-parser middleware
The bodyParser object exposes various factories to create middlewares. ... limit. Controls the maximum request body size. If this is a number, then...
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