From e90504b8cf1d73c36d902bbaaec7bab33f15c42e Mon Sep 17 00:00:00 2001 From: XIN_____ Date: Tue, 27 Jan 2026 19:05:25 -0600 Subject: [PATCH] Clarify error handlers are final and don't call next() (#7646) --- src/node/routes/errors.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/node/routes/errors.ts b/src/node/routes/errors.ts index da0ee8d7c..c1439d6ad 100644 --- a/src/node/routes/errors.ts +++ b/src/node/routes/errors.ts @@ -28,6 +28,12 @@ export const errorHasCode = (error: any): error is ErrorWithCode => { const notFoundCodes = [404, "ENOENT", "EISDIR"] +/** + * Final HTTP error handler. + * + * Note: This handler intentionally does not call `next()` even though it + * accepts it as an argument; it is expected to be mounted last. + */ export const errorHandler: express.ErrorRequestHandler = async (err, req, res, next) => { let statusCode = 500 @@ -61,6 +67,12 @@ export const errorHandler: express.ErrorRequestHandler = async (err, req, res, n } } +/** + * Final WebSocket error handler. + * + * Note: This handler intentionally does not call `next()` even though it + * accepts it as an argument; it is expected to be mounted last. + */ export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res, next) => { let statusCode = 500 if (errorHasStatusCode(err)) {