arena icon indicating copy to clipboard operation
arena copied to clipboard

`PayloadTooLargeError` if arena is initialized before bodyParser with higher size limit

Open squgeim opened this issue 6 years ago • 1 comments

If arena is added to an existing express application with a body parser initialized with a higher size limit, that size limit is not respected and a PayloadTooLargeError is thrown.

Example:

app.use(arena);

app.use(bodyParser.json({ limit: '5mb' }));

If a request body is larger than then default limit (I guess it is 100KB), a PayloadTooLargeError is thrown.

This works though:

app.use(bodyParser.json({ limit: '5mb' }));

app.use(arena);

squgeim avatar Sep 11 '18 08:09 squgeim

This is related to this https://github.com/expressjs/express/issues/1772.

If a sub-route is mounted to the root app, the middlewares are overridden, thus the bodyparser in arena overrides the middleware in the application.

One solution would be to mount arena in a subroute, but we can't do that due to this issue: https://github.com/bee-queue/arena/issues/105

squgeim avatar Sep 11 '18 09:09 squgeim