-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Why doesn't this code throw an error? #1004
Comments
For me it is a desire behavior. The reason is that every |
Fastify's default behavior is designed to swallow errors thrown after the response has been sent to prevent unhandled promise rejections or errors from crashing the Node.js process. your code can use Fastify hooks, specifically the onSend hook. const fastify = require('fastify')({ fastify.addHook('onSend', async (request, reply, payload) => { for (const route of myAbstractedRoutes) { fastify.listen({ port: 3000 }); |
@KerwinChina Add your code between code blocks in markdown. This is not readable. |
I've spent some time debugging my code to find an issue, and realized its the result of fastify swallowing any exceptions thrown after the reply is sent. My use case is I check all responses my routes send, against a strict schema. Is there a reason it's like this, or is it a bug in fastify? I'm aware fastify does log an error, but that doesn't help me handle/see the error.
Fastify Version: 4.26.2
Minimal reproduction
The text was updated successfully, but these errors were encountered: