Skip to content

fix: avoid state update after notifications modal unmount#40415

Open
davidmurdoch wants to merge 3 commits intomainfrom
fix/notifications-modal-unmount-state-update
Open

fix: avoid state update after notifications modal unmount#40415
davidmurdoch wants to merge 3 commits intomainfrom
fix/notifications-modal-unmount-state-update

Conversation

@davidmurdoch
Copy link
Contributor

@davidmurdoch davidmurdoch commented Feb 25, 2026

Description

The notifications activation modal was performing a no-op setIsLoading update during close only to run analytics side effects. If the modal unmounted during close, this could trigger React unmounted-update warnings. The fix removes the unnecessary state setter and keeps the tracking behavior by checking isLoading directly before hideModal().

I think this may fix a race condition that happens in our integration tests from time to time.

Changelog

CHANGELOG entry: null

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.

Note

Low Risk
Low risk: small change to notifications activation modal close behavior to remove a no-op state update and keep analytics tracking, with added tests to guard ordering and metrics emission.

Overview
Prevents React unmounted-update warnings when dismissing the notifications activation modal by removing the no-op setIsLoading call used only for side effects and instead conditionally tracking the "dismissed" metric directly before hideModal().

Adds/updates tests to assert dismissal metrics are sent and that trackEvent is invoked before the modal is hidden, reducing flakiness in the notifications activation integration flow.

Written by Cursor Bugbot for commit b55bd9b. This will update automatically on new commits. Configure here.

@github-actions
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.

@metamaskbot metamaskbot added the team-extension-platform Extension Platform team label Feb 25, 2026
@sonarqubecloud
Copy link

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 25, 2026

Builds ready [3d5a9e7]
⚡ Performance Benchmarks (1478 ± 128 ms)
👆 Interaction Benchmarks
ActionMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2979297310
total2979297310
Confirm Txconfirm_tx6017860226028
total6017860226028
Bridge User Actionsbridge_load_page22716235252
bridge_load_asset_picker20033216252
bridge_search_token72120736749
total11495412001217
🔌 Startup Benchmarks
BuildMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
Chrome Browserify Startup Standard HomeuiStartup14781228190412815531656
load12471023153410913291409
domContentLoaded12381013150410513221401
domInteractive2916107202684
firstPaint189711215162222353
backgroundConnect21919739624223249
firstReactRender20124462131
initialActions106123
loadScripts1039814129410511201205
setupStore1363351522
numNetworkReqs312291202284
Chrome Browserify Startup Power User HomeuiStartup3461155911156227540739616
load12981102200514913411644
domContentLoaded12791088195414513251633
domInteractive41202564035142
firstPaint2108548793284376
backgroundConnect16252679137201523266974
firstReactRender26185072842
initialActions106112
loadScripts1056887170214010931421
setupStore1675281829
numNetworkReqs85411542198119
Chrome Webpack Startup Standard HomeuiStartup9127741291999391119
load76765597791824949
domContentLoaded76165296990819940
domInteractive3217159262694
firstPaint1296834865153275
backgroundConnect32207483545
firstReactRender21124172536
initialActions105112
loadScripts75964996189817930
setupStore1466481529
numNetworkReqs312294192581
Chrome Webpack Startup Power User HomeuiStartup1293901314929013421735
load7476391168100743999
domContentLoaded7356331160100729989
domInteractive39181862939115
firstPaint1537550078179299
backgroundConnect1971311582164176346
firstReactRender23173942528
initialActions102011
loadScripts733631114998727977
setupStore1344361522
numNetworkReqs90471742395144
Firefox Browserify Startup Standard HomeuiStartup16471366240819716672069
load13811148212415414221649
domContentLoaded13801148211715314211644
domInteractive913337960100219
firstPaint------
backgroundConnect62302103063113
firstReactRender14112121416
initialActions103012
loadScripts13541132209214914001590
setupStore187171221534
numNetworkReqs311993192785
Firefox Browserify Startup Power User HomeuiStartup29482164968888530503512
load17031339725473917172030
domContentLoaded17021339725473917162030
domInteractive181421423177224438
firstPaint------
backgroundConnect471921291297710913
firstReactRender18145161821
initialActions103122
loadScripts16561313721974016461999
setupStore12910722155151490
numNetworkReqs90452343893183
Firefox Webpack Startup Standard HomeuiStartup17221465333426717382053
load14481206295724314731684
domContentLoaded14481206295624314721684
domInteractive833033052122167
firstPaint------
backgroundConnect63291983367142
firstReactRender15122721620
initialActions102122
loadScripts14211190291823914441564
setupStore227190261761
numNetworkReqs312094182780
Firefox Webpack Startup Power User HomeuiStartup27962169532641329593372
load15821302407834116642008
domContentLoaded15811302407734116592008
domInteractive18749832181179619
firstPaint------
backgroundConnect49611415243247721051
firstReactRender22167182430
initialActions205123
loadScripts15351280403233515971982
setupStore12919816173120610
numNetworkReqs87312323894161
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2171217218
srpButtonToSrpForm9319494
confirmSrpToPwForm2102122
pwFormToMetricsScreen1501516
metricsToWalletReadyScreen1601717
doneButtonToHomeScreen101128112591404
openAccountMenuToAccountListLoaded734540978347858
total884216888569097
Onboarding New WalletcreateWalletToSocialScreen2182218222
srpButtonToPwForm1061106108
createPwToRecoveryScreen8088
skipBackupToMetricsScreen3513637
agreeButtonToOnboardingSuccess1601617
doneButtonToAssetList87634711141432
total126634614961821
Asset DetailsassetClickToPriceChart4073852
total4073852
Solana Asset DetailsassetClickToPriceChart4824851
total4824851
Import Srp HomeloginToHomeScreen218025222802632
openAccountMenuAfterLogin54135877
homeAfterImportWithNewWallet250419726502804
total454919447164749
Send TransactionsopenSendPageFromHome2693638
selectTokenToSendFormLoaded2002020
reviewTransactionToConfirmationPage8564860861
total9034906909
SwapopenSwapPageFromHome10619123133
fetchAndDisplaySwapQuotes539182763926392
total549782864786526
🌐 Dapp Page Load Benchmarks

Current Commit: 3d5a9e7 | Date: 2/25/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±39ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 726ms (±36ms) 🟢 | historical mean value: 736ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±14ms) 🟢 | historical mean value: 83ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 39ms 1.01s 1.33s 1.06s 1.33s
domContentLoaded 726ms 36ms 707ms 1.00s 745ms 1.00s
firstPaint 79ms 14ms 64ms 208ms 84ms 208ms
firstContentfulPaint 79ms 14ms 64ms 208ms 84ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 765 Bytes (0.02%)
  • ui: -6.83 KiB (-0.08%)
  • common: 1.13 KiB (0.01%)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a React anti-pattern in the notifications activation modal where setIsLoading was being called purely for side effects (analytics tracking) without actually updating state. This could trigger React warnings if the modal unmounted during the close operation. The fix checks isLoading directly before calling hideModal(), eliminating the unnecessary state setter while preserving the analytics behavior.

Changes:

  • Refactored handleHideModal to check isLoading directly instead of using setIsLoading as a no-op wrapper for analytics tracking
  • Eliminated potential React unmounted-update warnings during modal close

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 27, 2026

Builds ready [b55bd9b]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account2702612828268282
total2702612828268282
Confirm Txconfirm_tx602960246032360326032
total602960246032360326032
Bridge User Actionsbridge_load_page24520727924258279
bridge_load_asset_picker21515131058250310
bridge_search_token7066997125706712
total1171109712806712131280
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14031172187311214321620
load1182100115849812151371
domContentLoaded117599515759712101356
domInteractive2817109202481
firstPaint147711179122191247
backgroundConnect21119227116217249
firstReactRender20124562132
initialActions106123
loadScripts98181213739510121157
setupStore1463771728
numNetworkReqs312289192581
Power User HomeuiStartup195813711031196619262435
load11881047172614911991610
domContentLoaded11751040171614511881593
domInteractive36181922834116
firstPaint216741608166273383
backgroundConnect3962505372536314643
firstReactRender23155482344
initialActions107114
loadScripts96082114991439731372
setupStore1563341623
numNetworkReqs63291663069141
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192182190219219
srpButtonToSrpForm96959609696
confirmSrpToPwForm22222202222
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen16161701617
doneButtonToHomeScreen926584153238112141532
openAccountMenuToAccountListLoaded75717212786129178497861
total881288098814288148814
Onboarding New WalletcreateWalletToSocialScreen2202202211220221
srpButtonToPwForm1101071122110112
createPwToRecoveryScreen999099
skipBackupToMetricsScreen36363603636
agreeButtonToOnboardingSuccess17161701717
doneButtonToAssetList571476724100595724
total9648671112989901112
Asset DetailsassetClickToPriceChart543277197677
total543277197677
Solana Asset DetailsassetClickToPriceChart61566636366
total61566636366
Import Srp HomeloginToHomeScreen1935188619984419521998
openAccountMenuAfterLogin40394214242
homeAfterImportWithNewWallet22952134250113624022501
total4216417443175841894317
Send TransactionsopenSendPageFromHome311740103940
selectTokenToSendFormLoaded20192112121
reviewTransactionToConfirmationPage86184487310870873
total91288093220929932
SwapopenSwapPageFromHome1049111810110118
fetchAndDisplaySwapQuotes53314620638485663756384
total54354724650285764676502
🌐 Dapp Page Load Benchmarks

Current Commit: b55bd9b | Date: 2/27/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±42ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 741ms (±40ms) 🟢 | historical mean value: 740ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 82ms (±9ms) 🟢 | historical mean value: 83ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 42ms 1.03s 1.36s 1.08s 1.36s
domContentLoaded 741ms 40ms 717ms 1.04s 766ms 1.04s
firstPaint 82ms 9ms 64ms 152ms 88ms 152ms
firstContentfulPaint 82ms 9ms 64ms 152ms 88ms 152ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.41 MiB (36.77%)
  • ui: -15.97 KiB (-0.19%)
  • common: -133.72 KiB (-1.18%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-S team-extension-platform Extension Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants