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: Remove old properties from state #29792

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Jan 17, 2025

Description

There are several kinds of errors in Sentry which indicate that there are properties in controller state we are attempting to persist that do not have corresponding metadata. This indicates that these properties were removed at some point from the controller's state but no migration was added that removed them from the persisted wallet state. In many cases, at the time of removal, such a migration was not needed because the controller in question inherited from BaseController v1. We have made a targeted effort over the past few years to migrate all controllers to BaseController v2, however, and so it matters now that every property have corresponding metadata or else are removed from state. We don't want these errors to show up in Sentry because they create noise, so this commit removes these properties from state.

Open in GitHub Codespaces

Related issues

Fixes #28289.
Fixes #28290.
Fixes #28300.
Fixes #28302.
Fixes #28344.
Fixes #28608.
Fixes #29746.

Manual testing steps

These changes should not affect users in any way since the errors we are trying to avoid occur out of band and should not crash anything.

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

delete state.NetworkController.networkConfigurations;
// Removed in 800a9d3a177446ff2d05e3e95ec06b3658474207 with a migration, but
// still persists for some people for some reason
delete state.NetworkController.providerConfig;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this error in Sentry: https://metamask.sentry.io/issues/6011869130/events/039861ddb07f4b39b947edba3bbd710e/. I am not sure why it is occurring. We already have a migration that removes this property. So do we need this here? Kind of strange that some people still have this property.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be due to some migration failure that we have not yet understood. I think it is good to attempt to delete again here, but we should investigate further if it continues to persist after this

delete state.PreferencesController.infuraBlocked;
// Removed in 4f66dc948fee54b8491227414342ab0d373475f1 with a migration, but
// still persists for some people for some reason
delete state.PreferencesController.useCollectibleDetection;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this error in Sentry here: https://metamask.sentry.io/issues/6042074159/events/5711f95785d741739e5d0fa5ad19e7c0/. Again we already have a migration that should be removing this property, so I'm not sure if this is needed?

@mcmire mcmire changed the title Remove old properties from state fix: Remove old properties from state Jan 17, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [f964268]
Page Load Metrics (1736 ± 65 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint29520601647331159
domContentLoaded14912048170913464
load15112063173613665
domInteractive266836126
backgroundConnect66123199
firstReactRender1678432311
getState45116178
initialActions01000
loadScripts10721519125811555
setupStore65615178
uiStartup17082281196214670
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.55 KiB (0.03%)
  • ui: 38 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

There are several kinds of errors in Sentry which indicate that there
are properties in controller state we are attempting to persist that do
not have corresponding metadata. This indicates that these properties
were removed at some point from the controller's state but no migration
was added that removed them from the persisted wallet state. In many
cases, at the time of removal, such a migration was not needed because
the controller in question inherited from BaseController v1. However, we
have made a targeted effort over the past few years to migrate all
controllers to BaseController v2, and so it matters now that every
property have corresponding metadata or else are removed from state. We
don't want these errors to show up in Sentry because they create noise,
so this commit removes these properties from state.
@mcmire mcmire force-pushed the remove-old-state-properties branch from f964268 to e69d847 Compare January 17, 2025 21:35
@metamaskbot
Copy link
Collaborator

Builds ready [e69d847]
Page Load Metrics (1768 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint34720881641455218
domContentLoaded14992063174015373
load15172095176815976
domInteractive268841178
backgroundConnect4101262914
firstReactRender1696472914
getState46218199
initialActions00000
loadScripts10591516127712359
setupStore687202613
uiStartup175627982058258124
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.55 KiB (0.03%)
  • ui: 38 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@mcmire mcmire marked this pull request as ready for review January 17, 2025 22:12
@metamaskbot
Copy link
Collaborator

Builds ready [f28fa49]
Page Load Metrics (1930 ± 229 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint34536251795649312
domContentLoaded151536041904482231
load157636191930477229
domInteractive25113472311
backgroundConnect77326209
firstReactRender18197464321
getState574232311
initialActions01000
loadScripts109127781434391188
setupStore67115189
uiStartup177944932297621298
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.65 KiB (0.03%)
  • ui: 38 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@mcmire mcmire requested a review from a team January 17, 2025 23:42
danjm
danjm previously approved these changes Jan 20, 2025
cryptodev-2s
cryptodev-2s previously approved these changes Jan 20, 2025
@mcmire mcmire dismissed stale reviews from cryptodev-2s and danjm via ec7ae60 January 20, 2025 20:26
@mcmire
Copy link
Contributor Author

mcmire commented Jan 20, 2025

@cryptodev-2s @danjm Oops, had to fix merge conflicts. Can I get another review?

@metamaskbot
Copy link
Collaborator

Builds ready [ec7ae60]
Page Load Metrics (1579 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14591957157911555
domContentLoaded14281942155611756
load14591964157911555
domInteractive237237157
backgroundConnect66421199
firstReactRender1597413115
getState45211136
initialActions01000
loadScripts10051434113710048
setupStore55113157
uiStartup16102245189619493
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.65 KiB (0.03%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@mcmire mcmire added this pull request to the merge queue Jan 21, 2025
Merged via the queue into main with commit fcb30d7 Jan 21, 2025
72 checks passed
@mcmire mcmire deleted the remove-old-state-properties branch January 21, 2025 16:25
@github-actions github-actions bot locked and limited conversation to collaborators Jan 21, 2025
@metamaskbot metamaskbot added the release-12.12.0 Issue or pull request that will be included in release 12.12.0 label Jan 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.