-
Notifications
You must be signed in to change notification settings - Fork 9
How to handle pre-handler exceptions #445
Comments
hapi already handles that for you through domains, you shouldn't have to do anything, unless you want to change the 500 reply. |
Hi Marsup, Thanks for the explanation.
Did I use pre-handler in wrong way? |
Are you on the latest version of hapi @bamoo456 ? I remember a similar issue to this came up before, but I thought it had been fixed. |
I tried on [email protected], it leaks, and I can't even explain it, but I only spent 5 minutes looking. |
This sounds like a bug in the way hapi handles pre-handlers. Calling reply inside a promise loses the domain binding for the second handler. Hapi assumes that all calls to See nodejs/node-v0.x-archive#8648 for some context on why the domain binding is lost inside promises. |
I have proposed a fix for hapi in hapijs/hapi#3448. |
@Marsup I thought this had been fixed!!
Maybe we need to look at using bluebird in core again? It seems there's constant issues with native promises and domains, I believe bluebird has much more built in to deal with all these edge cases around promise errors with domains... Edit: Nice work @kanongil, maybe I jumped the gun a little 😆 |
Hi @johnbrett Actually, I'm using |
I had a more beginner issue. I was thinking that when you do But returning an error from a pre seems to be a particular case, hapi just stop the request there and reply with the error. I think it is cool. |
Hi |
hapi version 17.8.5 |
@anuraggupta816 this is not how you ask for help. Open a new issue following the instructions. Make sure to provide all the requested information and to open it in the right place. Randomly posting to an issue and then pinging a bunch of people is rude. |
Hi,
I'm a novice in Hapi.js, does anyone knows how to handle unexpected exceptions in request lifecycle?
In other frameworks
(e.g. Koa.js)
, that will be a default error handler for unhandled exceptions and return500
errors back to clients.Just wondering to know if hapi.js support this kind of mechanism ?
The text was updated successfully, but these errors were encountered: