diff --git a/extension/dist/background.js b/extension/dist/background.js index 08e67191..fe310f3d 100644 --- a/extension/dist/background.js +++ b/extension/dist/background.js @@ -118,15 +118,8 @@ function registerListeners() { chrome.debugger.onDetach.addListener((source) => { if (source.tabId) attached.delete(source.tabId); }); - chrome.tabs.onUpdated.addListener((tabId, info) => { - if (info.url && !isDebuggableUrl$1(info.url)) { - if (attached.has(tabId)) { - attached.delete(tabId); - try { - chrome.debugger.detach({ tabId }); - } catch {} - } - } + chrome.tabs.onUpdated.addListener(async (tabId, info) => { + if (info.url && !isDebuggableUrl$1(info.url)) await detach(tabId); }); } //#endregion diff --git a/extension/src/cdp.ts b/extension/src/cdp.ts index fa195f76..c768e13e 100644 --- a/extension/src/cdp.ts +++ b/extension/src/cdp.ts @@ -158,12 +158,9 @@ export function registerListeners(): void { if (source.tabId) attached.delete(source.tabId); }); // Invalidate attached cache when tab URL changes to non-debuggable - chrome.tabs.onUpdated.addListener((tabId, info) => { + chrome.tabs.onUpdated.addListener(async (tabId, info) => { if (info.url && !isDebuggableUrl(info.url)) { - if (attached.has(tabId)) { - attached.delete(tabId); - try { chrome.debugger.detach({ tabId }); } catch { /* ignore */ } - } + await detach(tabId); } }); }