wxt icon indicating copy to clipboard operation
wxt copied to clipboard

Content script is incorrectly invalidated when injected multiple times

Open namukang opened this issue 2 months ago • 0 comments

Describe the bug

When a content script is injected multiple times, all but the most recent one should be invalidated. In practice however, all content scripts, including the most recent one, are invalidated.

Video going over the issue, the root cause, and the fix: https://www.loom.com/share/97983e5d38904af594d5f486bbf9f1f4?sid=e588c652-c868-4cb0-8db2-521650726919

Reproduction

Minimal reproduction: https://github.com/namukang/wxt-invalidation-bug

Steps to reproduce

Steps to reproduce:

  1. Clone https://github.com/namukang/wxt-invalidation-bug
  2. Run wxt dev
  3. Navigate to http://example.com
  4. Open the console
  5. Click the extension icon

Expected behavior

Only the first content script is invalidated.

Actual behavior

Both content scripts are invalidated.

System Info

System:
    OS: macOS 15.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.33 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - /Users/dk/.nvm/versions/node/v22.12.0/bin/node
    npm: 10.9.0 - /Users/dk/.nvm/versions/node/v22.12.0/bin/npm
    pnpm: 10.6.1 - /Users/dk/.nvm/versions/node/v22.12.0/bin/pnpm
    bun: 1.2.23 - /opt/homebrew/bin/bun
    Deno: 2.5.3 - /opt/homebrew/bin/deno
  Browsers:
    Brave Browser: 100.1.37.109
    Chrome: 141.0.7390.107
    Edge: 141.0.3537.71
    Firefox: 133.0.3
    Safari: 18.6
  npmPackages:
    wxt: ^0.20.11 => 0.20.11

Used Package Manager

pnpm

Validations

namukang avatar Oct 15 '25 08:10 namukang