fix(core): Fix WebSocket close codes

This commit is contained in:
Jan Oberhauser 2023-08-04 16:40:03 +02:00
parent 63ffe67dad
commit a8bfb46183

View file

@ -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;
}