diff --git a/app/gabsocial/stream.js b/app/gabsocial/stream.js index fad857557..b3ee6a6f9 100644 --- a/app/gabsocial/stream.js +++ b/app/gabsocial/stream.js @@ -76,9 +76,18 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken); ws.onopen = connected; - ws.onmessage = e => received(JSON.parse(e.data)); ws.onclose = disconnected; ws.onreconnect = reconnected; + ws.onmessage = (e) => { + if (!e.data) return; + try { + received(JSON.parse(e.data)); + } catch(error) { + console.error(e); + console.error(`Could not parse the above streaming event.\n${error}`) + } + } + return ws; };