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

fix: Import all scripts fix #24612

Merged
merged 3 commits into from
May 23, 2024
Merged

fix: Import all scripts fix #24612

merged 3 commits into from
May 23, 2024

Conversation

danjm
Copy link
Contributor

@danjm danjm commented May 20, 2024

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

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

  • I’ve followed MetaMask Coding Standards.
  • 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 format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@danjm danjm changed the title Import all scripts fix fix: Import all scripts fix May 21, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [321c043]
Page Load Metrics (1486 ± 564 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint601701063215
domContentLoaded9331352
load49307914861175564
domInteractive9331352
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@danjm danjm marked this pull request as ready for review May 23, 2024 19:47
@danjm danjm requested a review from a team as a code owner May 23, 2024 19:47
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label May 23, 2024
@DDDDDanica DDDDDanica merged commit e0c3c24 into develop May 23, 2024
75 of 77 checks passed
@DDDDDanica DDDDDanica deleted the import-all-scripts-fix branch May 23, 2024 20:13
@github-actions github-actions bot locked and limited conversation to collaborators May 23, 2024
@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
@metamaskbot
Copy link
Collaborator

Builds ready [5d7b649]
Page Load Metrics (1321 ± 609 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint661761043216
domContentLoaded9331453
load52308613211269609
domInteractive9331453
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template release-11.18.0 Issue or pull request that will be included in release 11.18.0 team-extension-platform
Projects
Archived in project
4 participants