Fetch file size error "PayloadTooLargeError: request entity too large"

When I am fetching a json file (15MB uncompressed or 800K gzip) I am getting the following error:

PayloadTooLargeError: request entity too large
    at readStream (<local_config>\node_modules\raw-body\index.js:155:17)
    at getRawBody (<local_config>\node_modules\raw-body\index.js:108:12)
    at read (<local_config>\node_modules\body-parser\lib\read.js:77:3)
    at jsonParser (<local_config>\node_modules\body-parser\lib\types\json.js:135:5)
    at Layer.handle [as handle_request] (<local_config>\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (<local_config>\node_modules\express\lib\router\index.js:317:13)
    at <local_config>\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (<local_config>\node_modules\express\lib\router\index.js:335:12)
    at next (<local_config>\node_modules\express\lib\router\index.js:275:10)
    at expressInit (<local_config>\node_modules\express\lib\middleware\init.js:40:5)

In my app, the fetch is being called from a redux action initiated by componentDidMount().

I assume this has something to do with the dev server, but since I’m new to this framework\language I’m not sure and search engine and Stackoverflow are not being helpful today.

I’ll add one more thing, for now I’m using a file, down the road I’ll have an API, but for today’s needs I’d like the file to work.

I’m surprised the 800K failed as well. That seemed more reasonable.
Any suggestions on how to get around this error?

Thanks!

I figured out that this was not my fetch, but console.log(). In my reducer, I had

console.log("Reducer Action: ", action);

And I was passing around a lot of data. When I removed that, or changed it to console.log("Reducer Action: ", action.type); the error went away.
Also, when I removed all my other console.log statement (not that many) my app performance improved and one very data heavy worked for the first time where previously it had been crashing.

console.log is bad I guess.

2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.