summaryrefslogtreecommitdiff
path: root/src/bg/RequestUtil.js
diff options
context:
space:
mode:
authorhackademix2018-07-22 16:50:24 +0200
committerhackademix2018-07-22 17:10:05 +0200
commit81b38512568982267b48f6df4ae15fb35ef1cc15 (patch)
tree22b0790750e2237a84c903a91d019f4d7b498771 /src/bg/RequestUtil.js
parente7fcd7670543a55e1eba5712c709231dd9f6a7fe (diff)
downloadnoscript-81b38512568982267b48f6df4ae15fb35ef1cc15.tar.gz
noscript-81b38512568982267b48f6df4ae15fb35ef1cc15.tar.xz
noscript-81b38512568982267b48f6df4ae15fb35ef1cc15.zip
Fixed dynamic script injection failing sometimes with "No matching message handler" error.
Diffstat (limited to 'src/bg/RequestUtil.js')
-rw-r--r--src/bg/RequestUtil.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bg/RequestUtil.js b/src/bg/RequestUtil.js
index b0fa913..659fd33 100644
--- a/src/bg/RequestUtil.js
+++ b/src/bg/RequestUtil.js
@@ -30,7 +30,14 @@
frameId,
}, details);
try {
- await browser.tabs.executeScript(tabId, details);
+ for (let attempts = 10; attempts-- > 0;) {
+ try {
+ await browser.tabs.executeScript(tabId, details);
+ } catch(e) {
+ if (!/No matching message handler/.test(e.message)) throw e;
+ debug("Couldn't inject script into %s: too early? Retrying up to %s times...", url, attempts);
+ }
+ }
count++;
debug("Execute on start OK", url, details);
} catch (e) {