mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01: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');
|
conn.send('pong');
|
||||||
return;
|
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);
|
await bus.parallel('connection/active', h);
|
||||||
if (conn.readyState === conn.OPEN) {
|
if (conn.readyState === conn.OPEN) {
|
||||||
|
|||||||
Reference in new issue
Block a user