Skip to content
Snippets Groups Projects
Commit 0ace009a authored by syuilo's avatar syuilo
Browse files

fix(server): Prevent error when recieve non-json data from websocket

Fix #6658
parent 48e8ee44
No related branches found
No related tags found
No related merge requests found
......@@ -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<string, any>;
try {
obj = JSON.parse(data.utf8Data);
} catch (e) {
return;
}
const { type, body } = obj;
switch (type) {
case 'api': this.onApiRequest(body); break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment