morgan-body
morgan-body copied to clipboard
If body is really big, morgan-body takes a LONG time even when maxBodyLength is set
Noting this as a point of improvement. I was sending post requests with really large bodies and even though I had set maxBodyLength
, morgan-body
was taking 30+ seconds to parse and print the request body.
I haven't looked into why this is happening, but I thought I'd mention it.
If helpful for others, I temporarily disabled the couple endpoints this was affecting by using the skip option for those endpoints to not log the request body.
function skipCriteria(req, res) {
if (
req.baseUrl === "/users/log" &&
req.method === "POST"
) {
return true;
}
return false;
}
morganBody(app, {
skip: skipCriteria,
});
Afaik, this issue should be fixed in v3, which is getting released soon, see PR #39
Could you give us more steps on how to reproduce this issue so we can take a deeper look into it?
Thanks in advance.
hmmm simplest way to deal with this would be to set a maximum size and not log the body if it's over that...
how long did it take? @mkausas
The body was about 1.5mb. It was sometimes taking 30+ seconds.
@VottusCode to reproduce send some large bodies with a post request. You can check the size of the request with one line to test out the 1.5mb: https://stackoverflow.com/questions/39653904/get-size-of-request
@VottusCode to reproduce send some large bodies with a post request. You can check the size of the request with one line to test out the 1.5mb: https://stackoverflow.com/questions/39653904/get-size-of-request
I will take a look in this soon. Thank you.