From a8bfb4618323731de8bc9bc265b3bbb9de69c50c Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Fri, 4 Aug 2023 16:40:03 +0200 Subject: [PATCH] fix(core): Fix WebSocket close codes --- packages/cli/src/push/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/push/index.ts b/packages/cli/src/push/index.ts index 09af08799..d5225b348 100644 --- a/packages/cli/src/push/index.ts +++ b/packages/cli/src/push/index.ts @@ -26,7 +26,7 @@ export class Push extends EventEmitter { } else if (!useWebSockets) { (this.backend as SSEPush).add(req.query.sessionId, { req, res }); } else { - res.status(401).send('Unauthorized'); + res.status(1008).send('Unauthorized'); } this.emit('editorUiConnected', req.query.sessionId); } @@ -73,7 +73,7 @@ export const setupPushHandler = (restEndpoint: string, app: Application) => { if (sessionId === undefined) { if (ws) { ws.send('The query parameter "sessionId" is missing!'); - ws.close(400); + ws.close(1008); } else { next(new Error('The query parameter "sessionId" is missing!')); } @@ -86,9 +86,9 @@ export const setupPushHandler = (restEndpoint: string, app: Application) => { } catch (error) { if (ws) { ws.send(`Unauthorized: ${(error as Error).message}`); - ws.close(401); + ws.close(1008); } else { - res.status(401).send('Unauthorized'); + res.status(1008).send('Unauthorized'); } return; }