Skip to content

Commit c7600a3

Browse files
committed
fix a crash on multiple websocket connections
1 parent c71723e commit c7600a3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/viewer/App.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,18 @@ const TimeStamp = ({time}: { time: Date }) => {
6161
};
6262

6363
function base64ToArrayBuffer(base64: string) {
64-
const binary_string = window.atob(base64);
65-
const len = binary_string.length;
64+
let binaryString: string;
65+
try {
66+
binaryString = window.atob(base64);
67+
} catch (e) {
68+
// TODO: the main reason for such an error is that currently there is no support for multiple websocket connections,
69+
// e.g. webpack hot reloaders.
70+
binaryString = "";
71+
}
72+
const len = binaryString.length;
6673
const bytes = new Buffer(len);
6774
for (let i = 0; i < len; i++) {
68-
bytes[i] = binary_string.charCodeAt(i);
75+
bytes[i] = binaryString.charCodeAt(i);
6976
}
7077
return bytes;
7178
}

0 commit comments

Comments
 (0)