Closed 10xLaCroixDrinker closed 8 months ago
I am closing this issue because nothing show the bug is exist inside this repository. Please minimize your reproducible snippet without any other plugins.
My suggestion is remove the async
from @autotelic/fastify-opentelemetry
.
So, it will respect the original function.
I am closing this issue because nothing show the bug is exist inside this repository. Please minimize your reproducible snippet without any other plugins.
Does the proposed solution not show that?
Does the proposed solution not show that?
Yes, consider the follow code working properly without @autotelic/fastify-opentelemetry
.
You should not force everyone to use async
or return Promise
.
instance.get('/ok', function(request, reply) {
setTimeout(function() {
reply.send('ok')
}, 1000)
})
The occur of FST_ERR_REP_ALREADY_SENT
is you are forking the promise chain.
The plugin you mention actually doing the following action.
// note the async here
instance.get('/ok', async function(request, reply) {
setTimeout(function() {
reply.send('ok') // you return to client inside timeout as well
}, 1000)
// you implicit return undefined which reply to client with empty string
})
Thanks for your help @climba03003. I opened a PR to @autotelic/fastify-opentelemetry
.
Prerequisites
Fastify version
4.26.0
Plugin version
7.0.0
Node.js version
20.10.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.6.1
Description
When using with
@autotelic/fastify-opentelemetry
including thewrapRoutes
option, requests for the statics result in an empty response and aFST_ERR_REP_ALREADY_SENT
error.Steps to Reproduce
I've pushed up a repo with the steps to reproduce and further details
https://github.com/10xLaCroixDrinker/fastify-static-issue-434
Expected Behavior
No response