Consolidated missing endpoint error detection in Messages.

This commit is contained in:
hackademix 2019-10-23 17:20:10 +02:00
parent 51e115d3bc
commit 810c607e6b
3 changed files with 6 additions and 2 deletions

View File

@ -62,7 +62,7 @@ var notifyPage = async () => {
return true;
} catch (e) {
debug(e);
if (/Receiving end does not exist/.test(e.message)) {
if (Messages.isMissingEndpoint(e)) {
window.setTimeout(notifyPage, 2000);
}
}

View File

@ -49,7 +49,7 @@
{id: "fetchPolicy", url, contextUrl: url});
break;
} catch (e) {
if (e.message !== "Could not esablish connection. Receiving end does not exist.") {
if (!Messages.isMissingEndpoint(e)) {
break;
}
error("Background page ready yet, retrying to fetch policy...")

View File

@ -65,6 +65,10 @@
return await browser.tabs.sendMessage(recipientInfo.tabId, args, opts);
}
return await browser.runtime.sendMessage(args);
},
isMissingEndpoint(error) {
return error && error.message ===
"Could not esablish connection. Receiving end does not exist.";
}
}
}