Does Express 5 catch async errors automatically?
Yes. Express 5 catches promise rejections from async handlers and passes them to the error handler. The asyncHandler wrapper is still useful for older versions.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Async Error Handling in Express: Best Practices
Wrap async handlers with asyncHandler: Promise.resolve(fn(req, res, next)).catch(next). The wrapper catches promise rejections and passes them to the error handler. Then you can throw inside async handlers.
Express 4 was designed before async/await. It does not catch promise rejections from async handlers. The handler returns a rejected promise that Express ignores, and the client hangs.
A safety net. process.on('unhandledRejection') and process.on('uncaughtException') catch what your middleware misses. They should not be your main strategy, but they prevent silent crashes. uncaughtException should usually exit the process.
Still have questions?
Browse all our FAQs or reach out to our support team
