Streaming: fail gracefully when WebSocket construction fails (mainly for Bromite browser)

This commit is contained in:
Alex Gleason 2021-10-20 16:36:38 -05:00
parent 0b94774fbe
commit 97cc7eb804
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -26,7 +26,12 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
}
};
const subscription = getStream(streamingAPIBaseURL, accessToken, path, {
let subscription;
// If the WebSocket fails to be created, don't crash the whole page,
// just proceed without a subscription.
try {
subscription = getStream(streamingAPIBaseURL, accessToken, path, {
connected() {
if (pollingRefresh) {
clearPolling();
@ -57,6 +62,9 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
},
});
} catch (e) {
console.error(e);
}
const disconnect = () => {
if (subscription) {