-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
catch async errors doesn't call next when there is no error, so it's useless #25
Comments
Also vanilla Express stuck into the middleware. You must call |
I know that, but this behavior renders the "catch async errors" useful only for terminal routes. |
From https://github.com/davidbanham/express-async-errors?tab=readme-ov-file#a-notice-about-calling-next
|
This comment was marked as outdated.
This comment was marked as outdated.
I can see in documentation that it's supposed to do that, but for some reason it doesn't work for me (hangs) even on normal Express const express = require("express");
require('express-async-errors');
const app = express();
app.set('env', 'production');
app.use(async (req, res) => {
console.log("mw", req.path);
});
app.get('/a', (req, res) => {
res.sendStatus(200);
});
app.listen(8080); |
express-async-errors monkey patch router and router/layer only can work with express! The only way is rewrite it for ultimate-express, eg. the first two lines from const Layer = require('express/lib/router/layer');
const Router = require('express/lib/router'); to const Layer = require('ultimate-express/src/router/layer');
const Router = require('ultimate-express/src/router'); This isn't an issue for ultimate-express but a bad design of express-async-errors |
Hi,
then this hangs
curl http://localhost:8080/a
.It would have been nicer if async middlewares had their next() method automatically called.
The text was updated successfully, but these errors were encountered: