From eea9dc68b9f6c95ad2b98a5410a0340ba2151640 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 7 Mar 2020 17:41:37 -0500 Subject: [PATCH] Fix runtime.lastError error on startup in Firefox --- ext/bg/js/backend.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 5b7ab084..4595dbb3 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -120,7 +120,8 @@ class Backend { this.clipboardMonitor.onClipboardText = this._onClipboardText.bind(this); this._sendMessageAllTabs('backendPrepared'); - chrome.runtime.sendMessage({action: 'backendPrepared'}); + const callback = () => this.checkLastError(chrome.runtime.lastError); + chrome.runtime.sendMessage({action: 'backendPrepared'}, callback); } _sendMessageAllTabs(action, params={}) { @@ -281,7 +282,8 @@ class Backend { _onApiYomichanCoreReady(_params, sender) { // tab ID isn't set in background (e.g. browser_action) if (typeof sender.tab === 'undefined') { - chrome.runtime.sendMessage({action: 'backendPrepared'}); + const callback = () => this.checkLastError(chrome.runtime.lastError); + chrome.runtime.sendMessage({action: 'backendPrepared'}, callback); return Promise.resolve(); }