Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error: PixieBrix contentScript already installed #428

Closed
fregante opened this issue Jun 4, 2021 · 3 comments · Fixed by #557
Closed

Uncaught Error: PixieBrix contentScript already installed #428

fregante opened this issue Jun 4, 2021 · 3 comments · Fixed by #557
Labels
bug Something isn't working developer experience

Comments

@fregante
Copy link
Collaborator

fregante commented Jun 4, 2021

Are you seeing this issue? I'm seeing one error in my Webpack 5 branch and 2 errors on main, whether it's the prod or dev build.

Possibly related to #398

VM422 contentScript.js:236942 Uncaught Error: PixieBrix contentScript already installed
    at Module.<anonymous> (VM414 contentScript.js:236942)
    at Module../src/contentScript.ts (VM414 contentScript.js:237016)
    at __webpack_require__ (VM414 contentScript.js:1440)
    at VM414 contentScript.js:1618
    at VM414 contentScript.js:1621

Screenshot taken with:

  1. main branch
  2. npm run watch:chrome
  3. Load extension manually from scratch
  4. Link account
  5. Open static HTML site
  6. Grant permission in dev tools
  7. Reload page

Screen Shot 11

@fregante fregante added the bug Something isn't working label Jun 4, 2021
@twschiller
Copy link
Contributor

twschiller commented Jun 5, 2021

Yep, I get the error almost always while using the dev tools (even when using Webpack 4). The error itself doesn't hurt anything - it's just a backstop against loading the contentScript module multiple times which would break things

An alternative might be split the content script entry point, and do an async import of the main functionality it hasn't already been loaded. I'm not sure what the performance hit on load time for that would be, though

There's a couple places (including dev tools) where we inject the content script if it hasn't already been injected. Here's what's likely the source of the error message you're seeing:

I suspect there's a race condition where the dev tools doesn't see the content script as having already been installed

I think it could be good to investigate this, as it might also reveal some opportunities to reduce latency in content script loading

@fregante
Copy link
Collaborator Author

I'm also seeing this tangentially-related error occasionally on Google.com with the PB dev tools open.

Screen Shot 8

@twschiller
Copy link
Contributor

twschiller commented Jun 20, 2021

I'm also seeing this tangentially-related error occasionally

That might somehow be related to this limitation?: w3c/webextensions#8. I haven't seen that warning before -- probably be a race condition on when various browser navigation events are happening?

I think testTabPermissions error/warning would have the opposite effect of preventing the background page from attempting to inject the script on behalf of the dev tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working developer experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants