summaryrefslogtreecommitdiff
path: root/src/server/api/stream
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-08-18 22:52:54 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-08-18 22:52:54 +0900
commit0ace009a54f6b781def9386298a2b053f3224bc6 (patch)
tree9ce7983494452b188f65d2ed5a392e543b9b0fc0 /src/server/api/stream
parentWebPのアニメーションが失われるのを修正 Fix #6625 (#6649) (diff)
downloadsharkey-0ace009a54f6b781def9386298a2b053f3224bc6.tar.gz
sharkey-0ace009a54f6b781def9386298a2b053f3224bc6.tar.bz2
sharkey-0ace009a54f6b781def9386298a2b053f3224bc6.zip
fix(server): Prevent error when recieve non-json data from websocket
Fix #6658
Diffstat (limited to 'src/server/api/stream')
-rw-r--r--src/server/api/stream/index.ts10
1 files changed, 9 insertions, 1 deletions
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<string, any>;
+
+ try {
+ obj = JSON.parse(data.utf8Data);
+ } catch (e) {
+ return;
+ }
+
+ const { type, body } = obj;
switch (type) {
case 'api': this.onApiRequest(body); break;