-
Notifications
You must be signed in to change notification settings - Fork 5.4k
release(runway): cherry-pick fix: cp-13.10.0 automatically restart the extension after MM is updated in order to work around the chromium bug https://issues.chromium.org/issues/40805401 #37948
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
base: release/13.10.0
Are you sure you want to change the base?
Conversation
…e extension after MM is updated in order to work around the chromium bug https://issues.chromium.org/issues/40805401 (#37552) <!-- 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** Automatically restart the extension after MM is updated in order to work around this chromium bug: https://issues.chromium.org/issues/40805401 It works by listening for the `onInstalled` event, and if it the `event.reason` is `"update"` and the `event.previousVersion` is NOT the current version, and the `event.previousVersion` has _not_ already been recorded in the `AppStateController`, we will reload the extension. [](https://codespaces.new/MetaMask/metamask-extension/pull/37552?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: Automatically restart the extension after MM is updated in order to work around this chromium bug: https://issues.chromium.org/issues/40805401 ## **Related issues** Fixes: #37503 (by hopefully making it unnecessary!) ## **Manual testing steps** ### Scenarios: #### Doesn't fire on initial installation 1. Install a version of the extension that does NOT have lavamoat (we need to use `globalThis.chrome`) and onboard 2. open the service worker/background console 3. logs starting with "[onUpdate]:" should not appear #### Doesn't reload before onboarding 1. close your browser completely (any and all Devtools panels too!) 2. re-open your browser 3. open the service_worker/background console 4. simulate an update event by running this code in the console: `chrome.runtime.onInstalled.dispatch({reason:"update", "previousVersion": "13.10.9"});` 5. should should see: `[onUpdate]: Should reload: undefined` (`undefined` indicates we didn't fetch our remote feature flags) in the logs #### Doesn't fetch feature flags until after onboarding (`Basic functionality` is left enabled during onboarding) 1. Monitor the Network tab for `https://client-config.api.cx.metamask.io/v1/flags` 2. Onboard 3. you shouldn't see https://client-config.api.cx.metamask.io/v1/flags until AFTER onboarding completes. _note: you can ensure we _don't_ fetch feature flags after onboarding by toggling `Basic functionality` to off as well._ #### Reloads after onboarding (`Basic functionality` is on) 1. close your browser completely (any and all Devtools panels too!) 2. re-open your browser 3. open the service_worker/background console 4. simulate an update event by running this code in the console: `chrome.runtime.onInstalled.dispatch({reason:"update", "previousVersion": "13.10.10"});` 5. it will reload only _once_. #### RPC Fallback still works 1. download a build from this PR (the build needs Quicknode ENV vars, which you probably don't have) 2. install and onboard 3. prevent connections to `mainnet.infura.io` however you'd like (probably via `/etc/hosts`) 4. Check the `service_worker` console and ensure quicknode URLs show up when you open the UI. <!-- ## **Screenshots/Recordings** ### **Before** ### **After** --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] 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/main/.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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds a safe-reload flow on extension update (Chromium, gated by a remote flag), defers/upgrades remote feature flag handling, and wires flags into NetworkController to enable/disable RPC failover; updates messengers, tests, and fixtures. > > - **Background**: > - Add `onUpdate` handler to record update metadata and trigger safe reload on Chromium when `extensionPlatformAutoReloadAfterUpdate` flag is true. > - Handle `runtime.onInstalled` update path asynchronously and invoke `onUpdate(controller, platform, previousVersion, requestSafeReload)`. > - Lazily fetch remote feature flags on UI open via `updateRemoteFeatureFlags` util. > - Simplify `setupController` signature (stop passing `requestSafeReload`). > - **Remote Feature Flags**: > - Initialize `RemoteFeatureFlagController` with persisted state; gate enablement by onboarding completion and `useExternalServices`. > - Subscribe to `PreferencesController` and `OnboardingController` state changes to enable/disable and refresh flags. > - Extend messengers to allow `RemoteFeatureFlagController:getState` and related `stateChange` events. > - **Network**: > - Use remote flag `walletFrameworkRpcFailoverEnabled` to set `NetworkController` `isRpcFailoverEnabled` at init and toggle on flag changes. > - **Tests/Fixtures**: > - Update unit tests to cover new messenger actions and RPC failover gating. > - Add `FixtureBuilder.withRemoteFeatureFlags` and set flags/manifest in e2e tests. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 802612e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Ganesh Suresh Patra <[email protected]> Co-authored-by: Mark Stacey <[email protected]> Co-authored-by: Mark Stacey <[email protected]>
|
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. |
✨ Files requiring CODEOWNER review ✨🔑 @MetaMask/accounts-engineers (1 files, +9 -1)
🧪 @MetaMask/qa (1 files, +8 -0)
|
Builds ready [a313e93]
UI Startup Metrics (1238 ± 115 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
Builds ready [de92669]
UI Startup Metrics (1224 ± 96 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
Builds ready [e987a18]
UI Startup Metrics (1224 ± 98 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
Builds ready [1a8aafd]
UI Startup Metrics (1212 ± 84 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
Builds ready [ba15bfa]
UI Startup Metrics (1220 ± 87 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
Description
Automatically restart the extension after MM is updated in order to work
around this chromium bug: https://issues.chromium.org/issues/40805401
It works by listening for the
onInstalledevent, and if it theevent.reasonis"update"and theevent.previousVersionis NOT thecurrent version, and the
event.previousVersionhas not already beenrecorded in the
AppStateController, we will reload the extension.Changelog
CHANGELOG entry: Automatically restart the extension after MM is updated
in order to work around this chromium bug:
https://issues.chromium.org/issues/40805401
Related issues
Fixes: #37503 (by hopefully making it unnecessary!)
Manual testing steps
Scenarios:
Doesn't fire on initial installation
need to use
globalThis.chrome) and onboardDoesn't reload before onboarding
chrome.runtime.onInstalled.dispatch({reason:"update", "previousVersion": "13.10.9"});[onUpdate]: Should reload: undefined(
undefinedindicates we didn't fetch our remote feature flags) in thelogs
Doesn't fetch feature flags until after onboarding (`Basic
functionality` is left enabled during onboarding)
https://client-config.api.cx.metamask.io/v1/flagsuntil AFTER onboarding completes.
note: you can ensure we don't fetch feature flags after onboarding by
toggling
Basic functionalityto off as well.Reloads after onboarding (
Basic functionalityis on)chrome.runtime.onInstalled.dispatch({reason:"update", "previousVersion": "13.10.10"});RPC Fallback still works
which you probably don't have)
mainnet.infura.iohowever you'd like(probably via
/etc/hosts)service_workerconsole and ensure quicknode URLs show upwhen you open the UI.
Pre-merge author checklist
Docs and MetaMask
Extension Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Adds Chromium-only safe reload after updates gated by a remote flag, defers remote feature-flag fetching until post-onboarding/UI open, and enables/disables RPC failover via remote flags, with messenger/test updates.
onUpdate(controller, platform, previousVersion, requestSafeReload); on extension update, record version and (non-Firefox) request safe reload whenremoteFeatureFlags.extensionPlatformAutoReloadAfterUpdateis true.updateRemoteFeatureFlags(controller); remove inline initializer.getRequestSafeReloadusage and removerequestSafeReloadparameter fromsetupController.lib/update-remote-feature-flags.tshelper.RemoteFeatureFlagControllerInit: use persisted state; enable/disable based on onboarding completion anduseExternalServices; subscribe toPreferencesandOnboardingchanges to toggle and fetch.OnboardingControllerstate/actions and subscribe to its changes.NetworkControllerInitreadsRemoteFeatureFlagController:getStateand subscribes tostateChangeto setisRpcFailoverEnabledfromremoteFeatureFlags.walletFrameworkRpcFailoverEnabled.RemoteFeatureFlagController:getStateandstateChangesupport.FixtureBuilder.withRemoteFeatureFlags; tests set flags (e.g.,enableMultichainAccountsState2,sendRedesign).Written by Cursor Bugbot for commit ba15bfa. This will update automatically on new commits. Configure here.
Co-authored-by: Ganesh Suresh Patra [email protected]
Co-authored-by: Mark Stacey [email protected]
Co-authored-by: Mark Stacey [email protected] 2eb650f