I know there is a new and improved Router looming on the horizon for Express 5 (tbd), but it would be nice to see at least basic support for promises/async functions in router handling for current Express (4).
What I'd like to see is a pretty basic, non-breaking change:
next(error) function if it is triggered.This would allow the following two handlers to behave identically:
router.use('/', (req, res) => {
throw new Error('oops');
});
router.use('/', async (req, res) => {
throw new Error('oops');
});
Hi @elliot-nelson ! This has been discussed numerous times, and it was found to be breaking for existing Express 4 apps in the wild, unfortunately, which is why it never landed in Express 4. It has, though, landed in the next router iteration, available for use to test, and in the current Express 5.
https://github.com/expressjs/express/issues/2259#issuecomment-433586394
Most helpful comment
Hi @elliot-nelson ! This has been discussed numerous times, and it was found to be breaking for existing Express 4 apps in the wild, unfortunately, which is why it never landed in Express 4. It has, though, landed in the next router iteration, available for use to test, and in the current Express 5.
https://github.com/expressjs/express/issues/2259#issuecomment-433586394