From 7443a4cb892a53929e09af6e40b90c68de4dc899 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 18 Jun 2017 15:20:11 +0300 Subject: [PATCH] ensure BG is initialized in onBackgroundReady() --- messaging.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/messaging.js b/messaging.js index e0be522a..83c4543a 100644 --- a/messaging.js +++ b/messaging.js @@ -296,17 +296,16 @@ function sessionStorageHash(name) { function onBackgroundReady() { - return BG ? Promise.resolve() : new Promise(ping); - function ping(resolve) { + return BG && BG.getStyles ? Promise.resolve() : new Promise(function ping(resolve) { chrome.runtime.sendMessage({method: 'healthCheck'}, health => { if (health !== undefined) { BG = chrome.extension.getBackgroundPage(); resolve(); } else { - ping(resolve); + setTimeout(ping, 0, resolve); } }); - } + }); }