Prevent invalid message format from crashing daemon

This commit is contained in:
hensm
2022-08-15 04:19:27 +01:00
parent 7ef96b6e43
commit 31c49b1678

View File

@@ -29,7 +29,12 @@ export function init(port: number, serverPassword?: string) {
messageStream._read = () => {};
socket.on("message", (message: string) => {
messageStream.push(JSON.parse(message));
try {
messageStream.push(JSON.parse(message));
} catch (err) {
// Catch parse errors and close socket
socket.close();
}
});
/**