Express

Error handler not recognized without four-argument signature

critical
configurationUpdated Feb 6, 2026(via Exa)
Technologies:
How to detect:

Express error-handling middleware must use exactly four arguments (err, req, res, next). Omitting the next parameter prevents Express from recognizing it as error middleware, causing errors to go uncaught

Recommended action:

Define error-handling middleware with signature (err, req, res, next). Always place error handler last in middleware stack, after all app.use() and route definitions. Check res.headersSent before sending response; if true, call next(err) to delegate to default handler