You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I saw in previous issues, v1 (Apparently) is supposed to catch errors thrown by middleware, however the current implementation wont be good enough for that.
In the examples, one is the first and two is a second middleware
Example handled by the current implementation:
function one(req, res, next) {
next();
}
function two(req, res, next) {
throw new Error("test");
}
Modified version that will not get caught:
function one(req, res, next) {
setImmediate(next);
}
function two(req, res, next) {
throw new Error("test");
}
As you can see, once a middleware finished in an async fashion, errors thrown by any middleware ran after it will not get caught, the reason for that is because the try/catch block will obviously be exit' since its an async operation.
To properly resolve this one would need to have the try/catch be within the wrapper loop() method.
The text was updated successfully, but these errors were encountered:
As I saw in previous issues, v1 (Apparently) is supposed to catch errors thrown by middleware, however the current implementation wont be good enough for that.
In the examples,
one
is the first andtwo
is a second middlewareExample handled by the current implementation:
Modified version that will not get caught:
As you can see, once a middleware finished in an async fashion, errors thrown by any middleware ran after it will not get caught, the reason for that is because the try/catch block will obviously be exit' since its an async operation.
To properly resolve this one would need to have the try/catch be within the wrapper loop() method.
The text was updated successfully, but these errors were encountered: