From 81b38512568982267b48f6df4ae15fb35ef1cc15 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sun, 22 Jul 2018 16:50:24 +0200 Subject: Fixed dynamic script injection failing sometimes with "No matching message handler" error. --- src/bg/RequestUtil.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/bg/RequestUtil.js') 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) { -- cgit v1.2.3