When there's an exception inside a route, Express seems to both silently swallow it and hang the request until it times out. It makes it very difficult to debug.
A basic repro is this:
var thirdPartyCode = function () {
// I can't change this
throw new Error("Bye");
}
app.get("/timeout", function (req, res, next) {
thirdPartyCode();
res.send("Never gets here");
});
The only way I've found to make it show the exception is to wrap the call to the third-party in try/catch.
In reality I've many different calls like this, and I'd rather not wrap each in try/catch if I can avoid it. Is there a better way?
- I'm not worried about how to recover from the state of the error, I just want to be notified if an uncaught exception like this occurs.
- I'm not able to add a call to next() inside the third-party code.
I've done a lot of NodeJS / Express error-handling searching already, but still can't find a way to solve this. Any specific suggestions would be great. Thanks.
via mikel
No comments:
Post a Comment