Consolidated missing endpoint error detection in Messages.
This commit is contained in:
parent
51e115d3bc
commit
810c607e6b
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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...")
|
||||
|
|
|
@ -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.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue