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

[Bug]: MV3 - Forcing Service Worker to stop throws error and MM stays loading app-init.js:1 Dropped attempt to register inpage content script. Error: Duplicate script ID 'inpage' #24514

Closed
seaona opened this issue May 14, 2024 · 2 comments · Fixed by #24612
Assignees
Labels
MV3 release-11.18.0 Issue or pull request that will be included in release 11.18.0 Sev2-normal Normal severity; minor loss of service or inconvenience. team-extension-platform type-bug

Comments

@seaona
Copy link
Contributor

seaona commented May 14, 2024

Describe the bug

[Edit] This behaviour has been identified also in cases where I didn't stop the service worker manually (see below comment).

Whenever I force the service worker to stop manually, I see the error app-init.js:1 Dropped attempt to register inpage content script. Error: Duplicate script ID 'inpage'and when I try to perform any action/refresh MM, I see that the wallet stays loading indefinitely.

To fix it, you need to click the Reload MM button.

Adding a Sev3 label, since I'm not sure in which situation this would happen, aside from manually stopping it.

Expected behavior

No response

Screenshots/Recordings

stop-sw-duplicate-script-id.mp4

Steps to reproduce

  1. Start MM MV3 build
  2. Go to chrome://serviceworker-internals/?devtools
  3. Stop Service Worker manually with the button
  4. Refresh MM
  5. See how it stays loading indefinetly

Error messages or log output

No response

Version

develop MV3 build

Build type

None

Browser

Chrome

Operating system

Linux

Hardware wallet

No response

Additional context

No response

Severity

No response

@seaona seaona added type-bug Sev3-low Low severity; minimal to no impact upon users MV3 team-extension-platform labels May 14, 2024
@seaona
Copy link
Contributor Author

seaona commented May 17, 2024

I've encountered this issue x2 more times, this case I haven't stopped the service worker manually. Just trying to open the MM popup and it stayed loading forever.The only way to recover is by clicking reload the app.

With this new finding, I'm bumping this to a sev-2 and possibly we need to re-evaluate if it's an MV3 blocker
cc @danjm @gauthierpetetin
I've encountered it when I leave the MM for some time idle and then try to open the pop

loading-indef.mp4

@seaona seaona added Sev2-normal Normal severity; minor loss of service or inconvenience. and removed Sev3-low Low severity; minimal to no impact upon users labels May 17, 2024
@danjm
Copy link
Contributor

danjm commented May 20, 2024

I'm looking at this now. It is definitely a blocker

DDDDDanica pushed a commit that referenced this issue May 23, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Fixes #24514.

The problem was that if the service worker is terminated, when
app-init.js runs again when the service worker is to be restarted,
`importAllScripts()` is not called. The solution is just to make sure it
is called in the top-level scope, on every run of the script. This
should be safe to do because of the `scriptsLoadInitiated` check already
in the `importAllScripts` function.

The PR also uses the `serviceworker.state` property to ensure that we
don't attempt to import scripts before installation. (That is explained
further in the code comment added in this PR)

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/24612?quickstart=1)

## **Related issues**

Fixes: #24514

## **Manual testing steps**

1. Start MM MV3 build
2. Go to chrome://serviceworker-internals/?devtools
3. Stop Service Worker manually with the button
4. You should be able to open MetaMask

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@metamaskbot metamaskbot added the release-11.18.0 Issue or pull request that will be included in release 11.18.0 label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MV3 release-11.18.0 Issue or pull request that will be included in release 11.18.0 Sev2-normal Normal severity; minor loss of service or inconvenience. team-extension-platform type-bug
Projects
Archived in project
Status: Fixed
Development

Successfully merging a pull request may close this issue.

3 participants