mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: ws: handle json parse error
This commit is contained in:
1 file changed
+11
-1
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user