-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationgood first issueGood for newcomersGood for newcomers
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the issue has not already been raised
Issue
https://fastify.dev/docs/latest/Reference/Hooks/#respond-to-a-request-from-a-hook
This code here
fastify.addHook('onRequest', (request, reply, done) => {
reply.send('Early response')
})
// Works with async functions too
fastify.addHook('preHandler', async (request, reply) => {
await something()
reply.send({ hello: 'world' })
return reply // mandatory, so the request is not executed further
})
The above docs imply that both hooks will run and returning reply is mandatory to stop processing, but in my experiments I found this to not be true.
There is also this issue that seems to back me up
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationgood first issueGood for newcomersGood for newcomers