Handle postMessage() errors

This commit is contained in:
Thomas Weber committed 2022-06-04 19:48:53 -05:00
1 parent ece89e3b66
commit da5ca2e188
1 file changed
+10 -3
+10 -3
View File
@@ -15,9 +15,16 @@ const importProjectFromOpener = ({
return;
}
const post = (data) => opener.postMessage({
p4: data
}, origin);
const post = (data) => {
// postMessage could throw if origin is invalid
try {
opener.postMessage({
p4: data
}, origin);
} catch (e) {
console.warn('Cannot post message', e);
}
};
let hasStarted = false;
let hasFinishedOrCancelled = false;