From be6edb4bc8e2c62f3ffac41e928091da6e19a1f9 Mon Sep 17 00:00:00 2001 From: Ariella Vu <20778143+digiwand@users.noreply.github.com> Date: Wed, 14 Dec 2022 01:21:32 +0700 Subject: [PATCH] scripts/ui: add tabs.query promise error handler (#16915) --- app/scripts/ui.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/scripts/ui.js b/app/scripts/ui.js index d335f60e5..b6753d567 100644 --- a/app/scripts/ui.js +++ b/app/scripts/ui.js @@ -18,6 +18,7 @@ import { PLATFORM_FIREFOX, } from '../../shared/constants/app'; import { isManifestV3 } from '../../shared/modules/mv3.utils'; +import { checkForLastErrorAndLog } from '../../shared/modules/browser-runtime.utils'; import { SUPPORT_LINK } from '../../shared/lib/ui-utils'; import { getErrorHtml } from '../../shared/lib/error-utils'; import ExtensionPlatform from './platforms/extension'; @@ -289,7 +290,12 @@ async function queryCurrentActiveTab(windowType) { return {}; } - const tabs = await browser.tabs.query({ active: true, currentWindow: true }); + const tabs = await browser.tabs + .query({ active: true, currentWindow: true }) + .catch((e) => { + checkForLastErrorAndLog() || log.error(e); + }); + const [activeTab] = tabs; const { id, title, url } = activeTab; const { origin, protocol } = url ? new URL(url) : {};