From ea9ff50702fccd5d813c43a78396834dc148150b Mon Sep 17 00:00:00 2001 From: Gareth Brown Date: Tue, 8 Dec 2020 18:30:36 +0000 Subject: [PATCH] Use execute script to reload page rather than chrome.tabs.reload() as chrome.runtime.reload() causes the previous operation to abort. --- hot-reload.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hot-reload.js b/hot-reload.js index 07bacd4..d6c0153 100644 --- a/hot-reload.js +++ b/hot-reload.js @@ -21,13 +21,12 @@ const reload = () => { chrome.tabs.query ({ active: true, currentWindow: true }, tabs => { // NB: see https://github.com/xpl/crx-hotreload/issues/5 - if (tabs[0]) { chrome.tabs.reload (tabs[0].id) } - { - setTimeout(function () { + if (tabs[0]) { - chrome.runtime.reload () - }, 500) + chrome.tabs.executeScript(tabs[0].id, {code: 'setTimeout(function () { location.reload(); }, 300)'}, function() {}); } + + chrome.runtime.reload () }) }