Closed paymog closed 12 months ago
Thanks for reporting!
Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.
Unfortunately I don't know how to reproduce since it happens quite rarely (1 request per 10million or something like that).
My guess is that you are missing an error handler inside onResponse
, e.g.:
onResponse(_, rep, res) {
const chunks: Uint8Array[] = [];
res.on('data', (chunk: Uint8Array) => {
chunks.push(chunk);
});
res.on('error', (err: Error) => {
reject(err);
});
res.on('end', () => {
const bodyBuffer = Buffer.concat(chunks);
resolve({ buffer: bodyBuffer, rep: rep as FastifyReply });
});
},
If increasing the timeout decreases the chance to reproduce it, then decreasing the timeout to the minimum should increase te chance to reproduce it.
@mcollina you have incredible intuition. I just deployed that suggestion and it seems to have resolved the issue. Thank you!
Prerequisites
Fastify version
4.1.0
Plugin version
9.0.1
Node.js version
18
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
alpine
Description
I often get full process crashes with stack traces like the following
The only place where I use undici is through this plugin. I was using the following config
and when I bumped the body timeout to
30000
the issue went away. However, I'd like to be able to figure out why my whole server crashes when one of these timeouts is encountered.I'm using this plugin like so:
Steps to Reproduce
Unfortunately I don't know how to reproduce since it happens quite rarely (1 request per 10million or something like that)
Expected Behavior
I expect body parsing errors to not kill the entire server but just break the request on which the error happens.