Skip to content

refactor(extension): reuse async detach() in registerListeners#328

Merged
jackwener merged 1 commit intomainfrom
refactor/async-detach-listeners
Mar 23, 2026
Merged

refactor(extension): reuse async detach() in registerListeners#328
jackwener merged 1 commit intomainfrom
refactor/async-detach-listeners

Conversation

@jackwener
Copy link
Owner

Follow-up to #322.

Replace the inline sync chrome.debugger.detach() in registerListeners onUpdated callback with the shared async detach() function.

Before

chrome.tabs.onUpdated.addListener((tabId, info) => {
  if (info.url && !isDebuggableUrl(info.url)) {
    if (attached.has(tabId)) {
      attached.delete(tabId);
      try { chrome.debugger.detach({ tabId }); } catch { /* ignore */ }
    }
  }
});

After

chrome.tabs.onUpdated.addListener(async (tabId, info) => {
  if (info.url && !isDebuggableUrl(info.url)) {
    await detach(tabId);
  }
});

This ensures consistent cleanup behavior across all detach paths and properly awaits the debugger detach. Extension build verified ✅ (16.62 kB).

Replace inline sync chrome.debugger.detach() in onUpdated listener
with the shared async detach() function for consistent cleanup behavior
across all detach paths.
@jackwener jackwener merged commit 56d4326 into main Mar 23, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant