SocketIORouter: Don't crash if message handler throws

This commit is contained in:
Richard Hansen 2021-09-06 05:51:57 -04:00
parent 320e5c1109
commit 9f9adb369b
2 changed files with 25 additions and 2 deletions

View file

@ -78,7 +78,11 @@ exports.setSocketIO = (_io) => {
return;
}
logger.debug(`from ${socket.id}: ${JSON.stringify(message)}`);
await components[message.component].handleMessage(socket, message);
try {
await components[message.component].handleMessage(socket, message);
} catch (err) {
logger.error(`Error while handling message from ${socket.id}: ${err.stack || err}`);
}
});
socket.on('disconnect', (reason) => {