-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugConfirmed bugConfirmed bug
Description
🐛 Bug Report
When calling reply.send within an async preValidation hook, this does not abort the request and thus emits a Response has already been sent error. Related: #677
According to the linked issue and pr, it should have been fixed, however it doesn't seem to be (At least for me):
To Reproduce
Hook:
fastify.addHook("preValidation", async function (request, reply) {
reply.code(403).send({error: "unauthenticated"});
});Handler:
module.exports = function (fastify, opts, next) {
fastify.get("/", {}, async (request, reply) => {
// This gets still executed, and reply.sent is true here
});
next();
}Expected behavior
The handler should not get called.
Your Environment
- node version: 10.16.0
- fastify version: >=2.5.0
- os: Windows, Linux
Metadata
Metadata
Assignees
Labels
bugConfirmed bugConfirmed bug