Repository navigation
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2610 +/- ##
=======================================
Coverage 79.64% 79.65%
=======================================
Files 138 138
Lines 4113 4118 +5
Branches 943 945 +2
=======================================
+ Hits 3276 3280 +4
+ Misses 740 739 -1
- Partials 97 99 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/browser
@wxt-dev/i18n
@wxt-dev/is-background
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/runner
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
|
@bompus Closed by mistake? |
|
Yes, sorry. I deleted my fork by accident, which closed this PR. I've reopened it as #2652 with the same change, rebased onto current main. |
|
@bompus No problem, i'll take a look on that tomorrow |
Overview
In MV3 dev,
reloadManifestContentScriptMv3registers a content script with a check-then-act sequence:getRegisteredContentScripts(), thenregisterContentScripts()if the id is absent. When twowxt:reload-content-scriptevents for the same entrypoint arrive close together, both read an empty registration and both register; the loser throwsDuplicate script ID 'wxt:content-scripts/<name>.js'.Nothing catches it.
reloadContentScriptcallsvoid reloadContentScriptMv3(payload), and the WebSocket listener does not await it, so the rejection lands as an unhandled promise rejection in the service worker.This PR catches the duplicate-id rejection inside
reloadManifestContentScriptMv3and returns. The winner is registering the identical script and reloads the matching tabs once its registration lands, so the loser has nothing left to do.Two alternatives that look reasonable and are not — both tried against a real dev session:
updateContentScriptsthrowsScript with ID '…' does not exist or is not fully registered, because the winner's registration is still in flight. That rejection aborts beforereloadTabsForContentScript, and the script is left unregistered.reloadTabsForContentScriptreloads the tab before the winner's registration lands, so the page comes back without the content script.The comment in the diff records both so neither gets reintroduced.
Manual Testing
The race is timing-dependent, so it does not reproduce on demand. It shows up on an MV3 project in
wxt devwhere several content script entrypoints share source, so one save emits multiple reload events in quick succession.I have been running this change as a local patch against
[email protected]in a project whose Playwright suite records service-worker unhandled rejections and fails any test that sees one. Before the change,Duplicate script IDfired roughly twice per 23-spec run. After it, three consecutive runs recorded noDuplicate script ID, nonot fully registered, and no other rejection; all 23 specs passed each time.There are no existing tests under
packages/wxt/src/virtual/, so none were added here. Happy to add one if there is a preferred harness for the virtual entrypoints.Related Issue
This PR closes #2609