Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
misha-panyushkin opened this issue Sep 3, 2019 · 7 comments
Closed

Comments

@misha-panyushkin
Copy link

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)

@75lb
Copy link
Member

75lb commented 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.

@misha-panyushkin
Copy link
Author

@75lb your approach helped me, many thanks! It should be mentioned that prior to run your code, I grabbed the latest version of lws.

@75lb
Copy link
Member

75lb commented Sep 3, 2019

OK, I'm glad we isolated the issue. However, I still need to fix lws-body-parser.

I'll look into adding a new option which increases the maximum size of files supported by body-parser. Let me know if you find any other issues! 👍

@75lb 75lb reopened this Sep 3, 2019
@misha-panyushkin
Copy link
Author

@75lb option for increasing size will be great!

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

@75lb 75lb changed the title Request entity too large at readStream add option to increase max file size supported by body-parser Sep 4, 2019
@tiagostutz
Copy link

Excluding flag is a great idea. And a option for increasing the limit would be nice, either.

Still needing help on this?

@75lb
Copy link
Member

75lb commented May 8, 2020

yes, both features are required - I will write some instructions later.. In the meantime, feel free to try some ideas!

75lb added a commit to lwsjs/body-parser that referenced this issue Jul 25, 2024
@75lb
Copy link
Member

75lb commented Aug 1, 2024

Fixed and released in local-web-server v5.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants