From 22fc754636719b4e1012f59b22f27d2e5b3811bb Mon Sep 17 00:00:00 2001 From: golem Date: Sat, 1 Aug 2026 22:30:37 -0600 Subject: [PATCH] fix: swallow rejections on the tab-open and menu-registration paths --- background/background.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/background/background.js b/background/background.js index e1c85ea..575b88a 100644 --- a/background/background.js +++ b/background/background.js @@ -52,19 +52,24 @@ async function readSelection() { } async function openChatGpt(query) { - const settings = await load(); - const url = buildChatGptUrl(settings, query); + try { + const settings = await load(); + const url = buildChatGptUrl(settings, query); - if (settings.openIn === "new-window") { - try { - await browser.windows.create({ url }); - return; - } catch { - // Fall through to a tab rather than doing nothing. + if (settings.openIn === "new-window") { + try { + await browser.windows.create({ url }); + return; + } catch { + // Fall through to a tab rather than doing nothing. + } } - } - await browser.tabs.create({ url, active: settings.openIn !== "background-tab" }); + await browser.tabs.create({ url, active: settings.openIn !== "background-tab" }); + } catch { + // Silence rejections silently — the user expects either a tab to open or + // nothing, not an error log. Every failure path must degrade gracefully. + } } // removeAll() first, so a background event page waking up and re-running this @@ -96,4 +101,7 @@ if (browser.commands) { }); } -registerMenu(); +registerMenu().catch(() => { + // Silence rejections from menus.removeAll() — it cannot prevent menu creation + // on retry, so degrade gracefully with no unhandled rejection logged. +});