Skip to content

Commit e90504b

Browse files
authored
Clarify error handlers are final and don't call next() (#7646)
1 parent 3c0b449 commit e90504b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/node/routes/errors.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export const errorHasCode = (error: any): error is ErrorWithCode => {
2828

2929
const notFoundCodes = [404, "ENOENT", "EISDIR"]
3030

31+
/**
32+
* Final HTTP error handler.
33+
*
34+
* Note: This handler intentionally does not call `next()` even though it
35+
* accepts it as an argument; it is expected to be mounted last.
36+
*/
3137
export const errorHandler: express.ErrorRequestHandler = async (err, req, res, next) => {
3238
let statusCode = 500
3339

@@ -61,6 +67,12 @@ export const errorHandler: express.ErrorRequestHandler = async (err, req, res, n
6167
}
6268
}
6369

70+
/**
71+
* Final WebSocket error handler.
72+
*
73+
* Note: This handler intentionally does not call `next()` even though it
74+
* accepts it as an argument; it is expected to be mounted last.
75+
*/
6476
export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res, next) => {
6577
let statusCode = 500
6678
if (errorHasStatusCode(err)) {

0 commit comments

Comments
 (0)