diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts index d420c6e794..36e08ec05f 100644 --- a/src/server/api/stream/index.ts +++ b/src/server/api/stream/index.ts @@ -71,7 +71,15 @@ export default class Connection { private async onWsConnectionMessage(data: websocket.IMessage) { if (data.utf8Data == null) return; - const { type, body } = JSON.parse(data.utf8Data); + let obj: Record; + + try { + obj = JSON.parse(data.utf8Data); + } catch (e) { + return; + } + + const { type, body } = obj; switch (type) { case 'api': this.onApiRequest(body); break;