Fix runtime.lastError error on startup in Firefox

This commit is contained in:
toasted-nutbread 2020-03-07 17:41:37 -05:00
parent 24d9001b14
commit eea9dc68b9

View File

@ -120,7 +120,8 @@ class Backend {
this.clipboardMonitor.onClipboardText = this._onClipboardText.bind(this); this.clipboardMonitor.onClipboardText = this._onClipboardText.bind(this);
this._sendMessageAllTabs('backendPrepared'); this._sendMessageAllTabs('backendPrepared');
chrome.runtime.sendMessage({action: 'backendPrepared'}); const callback = () => this.checkLastError(chrome.runtime.lastError);
chrome.runtime.sendMessage({action: 'backendPrepared'}, callback);
} }
_sendMessageAllTabs(action, params={}) { _sendMessageAllTabs(action, params={}) {
@ -281,7 +282,8 @@ class Backend {
_onApiYomichanCoreReady(_params, sender) { _onApiYomichanCoreReady(_params, sender) {
// tab ID isn't set in background (e.g. browser_action) // tab ID isn't set in background (e.g. browser_action)
if (typeof sender.tab === 'undefined') { 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(); return Promise.resolve();
} }