🐛 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
🐛 Bug Report
When calling
reply.sendwithin an async preValidation hook, this does not abort the request and thus emits aResponse has already been senterror. Related: #677According 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:
Handler:
Expected behavior
The handler should not get called.
Your Environment