Skip to content

Commit b1eb2b7

Browse files
committed
fix: enhance WebSocket error handling with status code logging
1 parent 7f2112c commit b1eb2b7

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/node/routes/errors.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,8 @@ export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res,
7373
} else {
7474
logger.debug(`${err.message} ${err.stack}`)
7575
}
76+
// Close the WebSocket connection with the appropriate HTTP status code.
77+
// We don't call next() here because the error has been fully handled:
78+
// the connection is closed and the error has been logged.
7679
;(req as WebsocketRequest).ws.end(`HTTP/1.1 ${statusCode} ${err.message}\r\n\r\n`)
7780
}

0 commit comments

Comments
 (0)