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

JSON body parser has a hardcoded limit of 1mb #168

Closed
trygve-lie opened this issue Jan 6, 2015 · 9 comments
Closed

JSON body parser has a hardcoded limit of 1mb #168

trygve-lie opened this issue Jan 6, 2015 · 9 comments

Comments

@trygve-lie
Copy link

The JSON body parser used to parse incoming requests has a hardcoded value of 1mb.

This is more or less fine when posting one and one document but a limit of 1mb becomes pretty small when one post documents with the bulk-docs route. The main reason for using the bulk-docs route is mainly to be able to post larger amounts of data in one go.

It is also the case that when trying to post something over 1mb one just get a 400 bad request in return and no indications on what the error is. It would have been nice to be able to see in some kind of log that one tried to post something above such a limit.

I think this should be configurable and perhaps different limits when posting single docs and bulk posting docs. I also think it should be some kind of log message if one try to post something above this.

I'll gladly create PR if you could give some advice on how you would like to handle this.

@marten-de-vries
Copy link
Member

Seems like CouchDB has a 4GB limit by default (http://docs.couchdb.org/en/latest/config/couchdb.html#couchdb/max_document_size). We could implement that config option too I guess. I do wonder if setting it to 4GB doesn't make it too easy to make the server run out of memory with just a few clients, though.

@trygve-lie
Copy link
Author

Yeah. That was pretty large, though for bulk uploads I can understand it. For single docs I don't.

Though; what if we made this configurable and follow the default value in CouchDB? Would you be happy with that?

@marten-de-vries
Copy link
Member

I guess there are easier ways to make express-pouchdb crash for now. And CouchDB probably has the same problem concerning running out of memory easily this way. I'd like some input from someone else though before definitly comitting to that solution.

@yaronyg
Copy link
Member

yaronyg commented Jan 8, 2015

This should really be a config option and ideally there should be a clear error associated with it so that the person running the server (and the person receiving the error) have some clue as to what happened. I also want a pony.

@trygve-lie
Copy link
Author

I agree with @yaronyg.

@marten-de-vries
Copy link
Member

Ok, then I'm fine with cloning PouchDB's behaviour (implementing /_config/couchdb/max_document_size with the 4GB default. As for an error, that makes sense. CouchDB probably throws one too, would be best to duplicate that one.)

@marten-de-vries
Copy link
Member

CouchDB's error is:
{error: "too_large", reason: "the request entity is too large"} with status code 413 Request Entity Too Large.

The exact default value is: 4 * 1024 * 1024 * 1024

@marten-de-vries
Copy link
Member

Implemented, I opened a PR: #179.

@marten-de-vries
Copy link
Member

e4d93f3

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

No branches or pull requests

3 participants