RXServer - nodejs PayloadTooLargeError: request entity too large
Yesterday using our software, based on RXDB with RXServer (Express) as backend, on a bigger live event than before, we suddenly experienced failed synchronizations. All the affected client was receiving was 413 Request entity too large. A look at the backend logs revealed, it was continuously throwing nodejs PayloadTooLargeError: request entity too large errors. Looking for the cause, it seems express limits json parsing by default to 1mb.
So as a dirty workaround, in RxServerAdapterExpress, create(), I changed app.use(express.json()); to app.use(express.json({limit: '500mb'})); and thing recovered.
Once app.use(express.json()); is called in the RxServerAdapterExpress function, further calls with different options are ignored.
Since (as far as I see), there currently is no possibility to give custom options to the Express adapter, what would be you're preferred design (@pubkey).
Or is there a (to me unknown) option on the client side to restrict the payload size?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.
This should be made possible. PR is welcomed.
@pubkey here a PR using the appOptions variable.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.
@pubkey do you need any more information? Can I help? Or what's the blocker here?
@fadnincx I checked and I cannot merge this. This would only work for the express based server adapter, not for fastify and koa. It should be possible to get the express instance in your own code and set the json limit after the server has been created?
@pubkey that was exactly why I was asking
what would be you're preferred design
I'm using the express instance in my code to provide different API endpoints besides RXDB. Until now, I was not able to successfully set the limit after the server has been created.
So another way I see would be, to give the user the possibility to submit it's own instance to the adapter.
Yes I think that would be the best solution. The adapter is only a few lines of code, so you would copy that and add any options there.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.
Issues are autoclosed after some time. If you still have a problem, make a PR with a test case or to prove that you have tried to fix the problem.