early response on error instead of proceeding with the lifecycle using next#8
early response on error instead of proceeding with the lifecycle using next#8salmanm wants to merge 2 commits intofastify:masterfrom salmanm:master
Conversation
mcollina
left a comment
There was a problem hiding this comment.
Can you add a unit test? Also I think we should call next(err).
|
I think calling |
|
I suppose in this case (missing auth header), we should be doing an early response from the hook. I don't think the control should ever reach the handler. I did test it locally and found it working. (Unless I've missed some case you're thinking) I'll add a unit test as soon as we come to a conclusion on this. |
That's true, right. We shouldn't call |
|
Added a test to ensure the correct response. |
delvedor
left a comment
There was a problem hiding this comment.
Hello! I fear I'm missing the issue here. We are already doing that internally.
https://github.com/fastify/fastify/blob/master/lib/hooks.js#L65-L68
https://github.com/fastify/fastify/blob/master/fastify.js#L326-L329
https://www.fastify.io/docs/latest/Lifecycle/
|
https://www.fastify.io/docs/latest/Hooks/#respond-to-a-request-from-a-hook
Isn't this a use case of the above pattern? We're in |
|
Closing as its fixed in #9 |
No description provided.