Why does my async middleware rejection not get caught?
Express 4 does not catch promise rejections from async middlewares. Wrap with Promise.resolve(fn(req, res, next)).catch(next) so rejections go to the error handler. Express 5 catches them automatically.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Common Express Middleware Mistakes (and How to Fix Them)
Forgetting next(), calling next() after responding, wrong order, sync heavy work, repeating middleware per route, sync throws in try/catch, async middleware without wrapper, mutating req.body without validating, error handler in the middle, and no error handler at all.
A middleware forgot to call next() or send a response. Every middleware must do one or the other. Without it, the request never ends and the client eventually times out.
No. Once you send a response, the cycle is over. Calling next() can lead to downstream code trying to respond again, causing 'headers already sent' errors. Use return res.json(...) to be safe.
Still have questions?
Browse all our FAQs or reach out to our support team
