mirror of
https://git.zavage.net/Zavage-Software/search-with-chatgpt-powered-by-openai-extension.git
synced 2026-08-10 13:40:29 -06:00
fix: swallow rejections on the tab-open and menu-registration paths
This commit is contained in:
parent
f683f2e841
commit
22fc754636
@ -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.
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user