Import all scripts fix
Description
Fixes https://github.com/MetaMask/metamask-extension/issues/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.
However, I am unsure why we were not doing this already... which makes me want to double check that there are no other reasons not to do this
Related issues
Fixes: https://github.com/MetaMask/metamask-extension/issues/24514
Manual testing steps
- Go to this page...
Screenshots/Recordings
Before
After
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.
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.
Builds ready [321c043]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1486 ± 564 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 60 | 170 | 106 | 32 | 15 |
| domContentLoaded | 9 | 33 | 13 | 5 | 2 | ||
| load | 49 | 3079 | 1486 | 1175 | 564 | ||
| domInteractive | 9 | 33 | 13 | 5 | 2 |
Bundle size diffs
- background: 0 Bytes (0.00%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Builds ready [5d7b649]
- builds: chrome, firefox
- builds (beta): chrome
- builds (flask): chrome, firefox
- builds (MMI): chrome, firefox
- builds (test): chrome, firefox
- builds (test-flask): chrome, firefox
- build viz: Build System
- mv3: Background Module Init Stats
- mv3: UI Init Stats
- mv3: Module Load Stats
- mv3: Bundle Size Stats
- mv2: E2e Actions Stats
- code coverage: Report
- storybook: Storybook
- typescript migration: Dashboard
- all artifacts
Page Load Metrics (1321 ± 609 ms)
| Platform | Page | Metric | Min (ms) | Max (ms) | Average (ms) | StandardDeviation (ms) | MarginOfError (ms) |
|---|---|---|---|---|---|---|---|
| Chrome | Home | firstPaint | 66 | 176 | 104 | 32 | 16 |
| domContentLoaded | 9 | 33 | 14 | 5 | 3 | ||
| load | 52 | 3086 | 1321 | 1269 | 609 | ||
| domInteractive | 9 | 33 | 14 | 5 | 3 |
Bundle size diffs
- background: 0 Bytes (0.00%)
- ui: 0 Bytes (0.00%)
- common: 0 Bytes (0.00%)
Missing release label release-11.16.6 on PR. Adding release label release-11.16.6 on PR and removing other release labels(release-11.18.0), as PR was cherry-picked in branch 11.16.6.