Discard streaming events with empty data

This commit is contained in:
Alex Gleason 2020-04-10 20:05:40 -05:00
parent af717ce3b8
commit 9769e0fb77
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -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;
};