Catching websocket errors to not take down whole process
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Fabian Stamm 2020-08-16 12:33:16 +02:00
parent c2cea4c15a
commit b3465ea96d
1 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,12 @@ export class WebsocketConnectionManager {
private static async onConnection(socket: WebSocket, req: IncomingMessage) {
Logging.log("New Connection:");
socket.on("error", (err) => {
Logging.error(err);
socket.close();
});
const sendError = (error: string) =>
socket.send(JSON.stringify({ ns: "error_msg", data: error }));