Skip to content

fix(extension): stop answering pings after the extension is uninstalled#30

Merged
winter100004 merged 1 commit into
mainfrom
fix/orphan-content-script-guard
Jun 11, 2026
Merged

fix(extension): stop answering pings after the extension is uninstalled#30
winter100004 merged 1 commit into
mainfrom
fix/orphan-content-script-guard

Conversation

@winter100004

Copy link
Copy Markdown
Contributor

What

After uninstalling (or reloading) the extension, its content script keeps running in already-open pages as an orphan: the window message listener stays alive, and since the ping handler touches no extension API, it kept answering — so the SDK's isAvailable() reported true until the page was refreshed, and an actual pick then failed with a misleading cancelled.

How

  • content/index.tsxextensionAlive() (browser.runtime?.id, try/catch since touching browser.runtime can throw in an invalidated context) + a guard at the top of the window message listener: once the extension is gone, unhook and go silent. An unanswered ping times out in the SDK → isAvailable() correctly reports false with no page refresh — the uninstall-side twin of the install-time backfill (feat(extension): inject content script into open tabs on install #29). A re-install injects a fresh isolated world and answers instead; the dead context can no longer double-answer.
  • Bumps the extension to 0.3.3.

Verification

  • typecheck ✅ · biome check ✅ · vitest run ✅ 110 passed · wxt zip ✅ (openpickerextension-0.3.3-chrome.zip)

🤖 Generated with Claude Code

When the extension is uninstalled (or reloaded), its content script keeps
running in already-open pages as an orphan: the window message listener stays
alive, and since the ping handler touches no extension API, it kept answering —
so the SDK's isAvailable() reported true until the page was refreshed (and an
actual pick then failed with a misleading "cancelled").

Guard the message listener: when the extension context is invalidated
(browser.runtime.id gone, or touching browser.runtime throws), unhook and go
silent. An unanswered ping times out in the SDK, so isAvailable() correctly
reports false with no page refresh — the uninstall-side twin of the
install-time backfill. A re-install injects a fresh isolated world and answers
instead; the dead context can no longer double-answer.

Bumps the extension to 0.3.3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@winter100004
winter100004 merged commit 5551585 into main Jun 11, 2026
1 check passed
@winter100004
winter100004 deleted the fix/orphan-content-script-guard branch June 11, 2026 06:39
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