core: ws: handle json parse error

This commit is contained in:
undefined committed 2024-03-29 16:43:46 +08:00
1 parent f0219116f3
commit c7ae61df93
1 file changed
+11 -1
+11 -1
View File
@@ -459,7 +459,17 @@ export function Connection(
conn.send('pong');
return;
}
h.message?.(JSON.parse(e.data.toString()));
let payload;
try {
payload = JSON.parse(e.data.toString());
} catch {
conn.close();
}
try {
h.message?.(payload);
} catch (err) {
logger.error(e);
}
};
await bus.parallel('connection/active', h);
if (conn.readyState === conn.OPEN) {