Skip to content

fix(useAsyncCallback): update component mount state handling to prevent ref issues in StrictMode - #45285

Merged
Prithpal-Sooriya merged 1 commit into
mainfrom
fix/useAsyncCallback-strictmode-fix
Aug 7, 2026
Merged

fix(useAsyncCallback): update component mount state handling to prevent ref issues in StrictMode#45285
Prithpal-Sooriya merged 1 commit into
mainfrom
fix/useAsyncCallback-strictmode-fix

Conversation

@Prithpal-Sooriya

@Prithpal-Sooriya Prithpal-Sooriya commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

This useAsyncCallback in dev StrictMode loses its data on refire (via unmount/remount). Caused issues with token details page opening

Changelog

CHANGELOG entry: fix(useAsyncCallback): update component mount state handling to prevent ref issues in StrictMode

Related issues

Fixes: N/A

Manual testing steps

  1. Go to search
  2. Select Token you don't own
  3. Expected Token Details Page Opens

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.

Note

Low Risk
Two-line hook lifecycle change; fixes dev StrictMode behavior without altering production mount/unmount semantics.

Overview
useAsyncCallback now sets isMounted.current = true when its mount effect runs, not only on cleanup to false. In React StrictMode (dev), the simulated unmount left the ref false after remount, so execute could bail out immediately and async results never updated—e.g. token details after search.

useAsyncResult inherits the fix because it builds on useAsyncCallback.

Reviewed by Cursor Bugbot for commit 7b70295. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
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.

@dan437

dan437 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I also ran into this issue, Network fee was not loading in the Send flow.

@MajorLift MajorLift left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good call. Also documented this in this ticket for defining a useIsMounted hook: https://github.com/MetaMask/MetaMask-planning/issues/6544

@DDDDDanica

Copy link
Copy Markdown
Contributor

Thanks so much for the quick fix 🙏🏻

@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@metamask-ci

metamask-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
Builds ready [7b70295]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 16 warn · 🔴 1 fail)

Baseline (latest main): 171ed20 | Date: 7/28/2026 | Pipeline: 31103431545 | Baseline logs

Metricschrome-webpackfirefox-webpack
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 1 failure)

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟡 [CI log]
🟡 load_new_account
🟡 [CI log]
🟡 load_new_account
confirmTx
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: +18%
  • loadNewAccount/total: +18%
  • confirmTx/longTaskTotalDuration: -16%
  • confirmTx/longTaskMaxDuration: +36%
  • confirmTx/tbt: -28%
  • bridgeUserActions/bridge_load_asset_picker: +53%
  • bridgeUserActions/longTaskCount: -44%
  • bridgeUserActions/longTaskTotalDuration: -56%
  • bridgeUserActions/longTaskMaxDuration: -35%
  • bridgeUserActions/tbt: -80%
  • loadNewAccount/load_new_account: +21%
  • loadNewAccount/total: +21%
  • loadNewAccount/inp: -24%
  • loadNewAccount/fcp: -47%
  • loadNewAccount/lcp: +1194%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/inp: -32%
  • confirmTx/lcp: +1226%
  • bridgeUserActions/bridge_load_page: +199%
  • bridgeUserActions/bridge_load_asset_picker: +85%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +205%
  • bridgeUserActions/inp: -23%
  • bridgeUserActions/fcp: -48%
  • bridgeUserActions/lcp: +1114%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 confirmTx/FCP: p75 1.8s
  • 🟡 confirmTx/FCP: p75 1.8s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 loadScripts
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/firstReactRender: -99%
  • startupStandardHome/numNetworkReqs: -14%
  • startupStandardHome/domInteractive: -17%
  • startupStandardHome/firstReactRender: -98%
  • startupStandardHome/initialActions: -50%
  • startupStandardHome/numNetworkReqs: -13%
  • startupPowerUserHome/uiStartup: -19%
  • startupPowerUserHome/firstReactRender: -99%
  • startupPowerUserHome/initialActions: +11%
  • startupPowerUserHome/setupStore: -70%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 startupPowerUserHome/LCP: p75 2.6s
User Journey Benchmarks · Samples: 5 · mock API 🔴 1
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟡 [CI log]
🟡 total
🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]
🔴 total
🔴 [CI log]
🔴 total
assetDetails
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
importSrpHome
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
sendTransactions
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]
swap
[Sentry log · main/release]
🟡 [CI log]
🟡 total
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: +12%
  • onboardingImportWallet/metricsToWalletReadyScreen: -10%
  • onboardingImportWallet/doneButtonToHomeScreen: -78%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -52%
  • onboardingImportWallet/longTaskCount: -86%
  • onboardingImportWallet/longTaskTotalDuration: -95%
  • onboardingImportWallet/longTaskMaxDuration: -92%
  • onboardingImportWallet/tbt: -99%
  • onboardingImportWallet/total: -81%
  • onboardingNewWallet/longTaskCount: -38%
  • onboardingNewWallet/longTaskTotalDuration: -46%
  • onboardingNewWallet/longTaskMaxDuration: -23%
  • onboardingNewWallet/tbt: -62%
  • solanaAssetDetails/assetClickToPriceChart: +318%
  • solanaAssetDetails/longTaskCount: -100%
  • solanaAssetDetails/longTaskTotalDuration: -100%
  • solanaAssetDetails/longTaskMaxDuration: -100%
  • solanaAssetDetails/tbt: -100%
  • solanaAssetDetails/total: +318%
  • solanaAssetDetails/inp: +11%
  • solanaAssetDetails/fcp: +21%
  • importSrpHome/loginToHomeScreen: -14%
  • importSrpHome/homeAfterImportWithNewWallet: -12%
  • importSrpHome/longTaskCount: -44%
  • importSrpHome/longTaskTotalDuration: -46%
  • importSrpHome/longTaskMaxDuration: -17%
  • importSrpHome/tbt: -44%
  • importSrpHome/total: -12%
  • importSrpHome/inp: -38%
  • importSrpHome/fcp: +12%
  • importSrpHome/cls: +519%
  • sendTransactions/selectTokenToSendFormLoaded: +57%
  • sendTransactions/reviewTransactionToConfirmationPage: -97%
  • sendTransactions/longTaskCount: -100%
  • sendTransactions/longTaskTotalDuration: -100%
  • sendTransactions/longTaskMaxDuration: -100%
  • sendTransactions/tbt: -100%
  • sendTransactions/total: -94%
  • sendTransactions/inp: -19%
  • sendTransactions/fcp: +14%
  • sendTransactions/lcp: -60%
  • sendTransactions/cls: +171%
  • swap/openSwapPageFromHome: +883%
  • swap/fetchAndDisplaySwapQuotes: +135%
  • swap/longTaskCount: +33%
  • swap/longTaskTotalDuration: -16%
  • swap/longTaskMaxDuration: -12%
  • swap/tbt: -100%
  • swap/total: +149%
  • swap/lcp: -71%
  • swap/cls: -92%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 solanaAssetDetails/FCP: p75 1.9s
  • 🟡 importSrpHome/FCP: p75 1.9s
  • 🟡 sendTransactions/FCP: p75 1.9s
  • 🟡 swap/FCP: p75 1.9s
  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 solanaAssetDetails/FCP: p75 1.9s
  • 🟡 importSrpHome/FCP: p75 1.9s
  • 🔴 sendTransactions/INP: p75 560ms
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: -58%
  • dappPageLoad/firstPaint: -46%
  • dappPageLoad/firstContentfulPaint: -46%
Bundle size diffs
  • background: 105 Bytes (0%)
  • ui: 64 Bytes (0%)
  • common: 0 Bytes (0%)
  • other: 0 Bytes (0%)
  • contentScripts: 0 Bytes (0%)
  • zip: 52 Bytes (0%)

@Prithpal-Sooriya
Prithpal-Sooriya added this pull request to the merge queue Aug 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 6, 2026
@dan437
dan437 added this pull request to the merge queue Aug 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 7, 2026
@Prithpal-Sooriya
Prithpal-Sooriya added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit f1790c6 Aug 7, 2026
150 checks passed
@Prithpal-Sooriya
Prithpal-Sooriya deleted the fix/useAsyncCallback-strictmode-fix branch August 7, 2026 14:36
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2026
@metamaskbot metamaskbot added the release-13.45.0 Issue or pull request that will be included in release 13.45.0 label Aug 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.45.0 Issue or pull request that will be included in release 13.45.0 size-XS team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants