From b1eb2b78af09d2a4a4fbf3c40d9c4e686573213a Mon Sep 17 00:00:00 2001 From: taoxin Date: Sat, 24 Jan 2026 20:42:55 +0800 Subject: [PATCH] fix: enhance WebSocket error handling with status code logging --- src/node/routes/errors.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node/routes/errors.ts b/src/node/routes/errors.ts index da0ee8d7c..6a297e5fb 100644 --- a/src/node/routes/errors.ts +++ b/src/node/routes/errors.ts @@ -73,5 +73,8 @@ export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res, } else { logger.debug(`${err.message} ${err.stack}`) } + // Close the WebSocket connection with the appropriate HTTP status code. + // We don't call next() here because the error has been fully handled: + // the connection is closed and the error has been logged. ;(req as WebsocketRequest).ws.end(`HTTP/1.1 ${statusCode} ${err.message}\r\n\r\n`) }