-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: cp-13.14.2 Guard against invalid controller state #39465
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
Conversation
During the `setupController` method in `background.js`, it will throw an error during initialization if any "controllers with persisted state" have something other than an object as their state (e.g. `undefined` or `null` or a primitive). This should be impossible due to type checks, but we're seeing it happen anyway. This code has been updated to report the error and continue initialization without interruption. There is still a root cause here to fix, but we can address that in a follow-up PR (it may take more time to learn what the root cause is). Fixes #39464
Builds ready [d7f9f88]
UI Startup Metrics (1242 ± 112 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
davidmurdoch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually tested and can confirm that it fixes the issue.
Builds ready [217ff83]
UI Startup Metrics (1275 ± 119 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
|
This PR updates the change log for 13.14.2. (Hotfix - no test plan generated.) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Updates release notes. > > - Adds `13.14.2` section with a fix: prevent crash during initialization when a controller has invalid state (#39465) > - Updates `[Unreleased]` compare link to start from `v13.14.2` and adds `[13.14.2]` compare reference > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d8bca06. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: metamaskbot <[email protected]> Co-authored-by: Mark Stacey <[email protected]>
Description
During the
setupControllermethod inbackground.js, it will throw an error during initialization if any "controllers with persisted state" have something other than an object as their state (e.g.undefinedornullor a primitive). This should be impossible due to type checks, but we're seeing it happen anyway.This code has been updated to report the error and continue initialization without interruption. There is still a root cause here to fix, but we can address that in a follow-up PR (it may take more time to learn what the root cause is).
Changelog
CHANGELOG entry: Prevent crash during initialization when some controller has invalid state.
Related issues
Fixes #39464
Manual testing steps
loading.htmlpageloading.htmlagain, and runawait chrome.storage.local.get()to confirm that the state was set correctly (fooandbarshould be present). If not, try again.Screenshots/Recordings
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Prevents initialization from crashing when a controller has invalid (non-object) state by reporting and skipping it.
captureExceptionimportsetupController(inbackground.js), guards each controller state: ifnullor not an object, report viacaptureExceptionand continue; otherwise proceed with change detection/persistenceWritten by Cursor Bugbot for commit 217ff83. This will update automatically on new commits. Configure here.