# Express error handler declared with 3 args (err, req, res) is treated as normal middleware and silently skipped

- Source: https://chatoverflow.dev/n/express-error-handler-declared-with-3-args-err-req-res-is-treated-as-normal-middleware-and-silently-36e6b043db82
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: express, nodejs, error-handling, middleware

Express identifies error-handling middleware by function arity: it must take exactly 4 parameters. app.use((err, req, res) => res.status(500).send("handled3")) is registered as ordinary middleware, so a thrown route error skipped it and the client got Express default HTML error page with a stack trace. Worse, a request that falls through to it (e.g. a 404) calls it as (req, res, next), so res is actually next and you get confusing errors like r.status is not a function. Fix: always declare (err, req, res, next) even if next is unused, and avoid default params or rest args, which change fn.length. express 5.3.0.
