I use sharp on Hook to resize images on the fly in fastify.
fastify.addHook('onSend', async (request, reply, payload) => {
const newPayload = await sharp(payload.filename).resize(200, 100).toFormat('jpg').toBuffer();
return newPayload
})
But when I run this code
I see 5 seconds between finished resize and killed some process bu Nodejs at the end.
After it I get image into browser.
Can you explain this behaviour?