Skip to content

fix(ui): reload extension safely from error Try again in popup#41364

Merged
gauthierpetetin merged 2 commits into
mainfrom
fix/29151-error-try-again-reload
Apr 2, 2026
Merged

fix(ui): reload extension safely from error Try again in popup#41364
gauthierpetetin merged 2 commits into
mainfrom
fix/29151-error-try-again-reload

Conversation

@gauthierpetetin

@gauthierpetetin gauthierpetetin commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Description

Clicking Try again on the global error screen or Shield API error UI used to call browser.runtime.reload() from the extension UI document. In Chromium, that can leave a popup-style window showing normal tab content (e.g. the new-tab page) instead of restarting MetaMask cleanly (GitHub issue #29151).

This change routes recovery through requestSafeReload in the service worker: persistence is flushed, runtime.reload() is scheduled after a short delay, and reloadExtensionFromUi calls requestSafeReload then window.close() so the window is dismissed before reload. Error page and API error handler Try again actions use the shared helper instead of calling browser.runtime.reload() directly.

Changelog

CHANGELOG entry: Fixed an issue where choosing Try again on some error screens could show the browser’s default page inside the MetaMask window instead of restarting the extension.

Related issues

Fixes: #29151

Manual testing steps

  1. Build extension withyarn start and open it.
  2. Use https://metamask.github.io/test-dapp/ → Connect → Malformed signaturesInvalid type → expand Message on the confirmations screen → confirm the error screen appears.
  3. Click Try again: the popup should close and the extension should reload; the popup should not show your browser’s home/new-tab page inside MetaMask.
  4. Optional: Settings → Developer options → Generate a page crash (expanded view) → Try again and confirm recovery still works.

Screenshots/Recordings

Before

fix.ui._.reload.extension.safely.from.error.Try.again.in.popup.by.gauthierpetetin.Pull.Request.41364.MetaMask_metamask-extension.-.31.March.2026.mp4

After

fix.ui._.reload.extension.safely.from.error.Try.again.in.popup.by.gauthierpetetin.Pull.Request.41364.MetaMask_metamask-extension.-.31.March.2026.1.mp4

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
Small, localized change to reload sequencing and UI event handlers; main risk is timing-sensitive reload behavior across extension surfaces.

Overview
Fixes UI-triggered extension reloads to avoid Chromium popup/notification windows briefly showing normal tab content. requestSafeReload now delays runtime.reload() slightly after flushing pending persistence writes, and UI surfaces (Error Page and Shield API error handler) route “Try again” through a new reloadExtensionFromUi helper that calls requestSafeReload then window.close(), with a fallback to direct runtime.reload() if the background request fails.

Adds unit coverage for the new helper and updates existing error-page tests to assert the helper is invoked instead of calling browser.runtime.reload() directly.

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

- Defer runtime.reload in requestSafeReload after persistence flush
- Add reloadExtensionFromUi helper (requestSafeReload + window.close)
- Use helper on error page and Shield API error handler

Fixes #29151

Made-with: Cursor
@github-actions

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.

@metamaskbot metamaskbot added the team-extension-platform Extension Platform team label Mar 30, 2026
@gauthierpetetin gauthierpetetin self-assigned this Mar 30, 2026
@metamaskbotv2

metamaskbotv2 Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor
Builds ready [97a55c6]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account1114100911866611471186
total1114100911866611471186
Confirm Txconfirm_tx6026600060451760366045
total6026600060451760366045
Bridge User Actionsbridge_load_page32126338343354383
bridge_load_asset_picker22515031675312316
bridge_search_token85581589932868899
total13761193149910814701499
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Startup Standard HomeuiStartup14991261182210115531655
load1231102515269112811343
domContentLoaded1223101815149012741327
domInteractive2817144162948
firstPaint1767036480245314
backgroundConnect21218627913216237
firstReactRender20134652230
initialActions106124
loadScripts102883813148710781127
setupStore1373051524
numNetworkReqs35315973849
Startup Power User HomeuiStartup4386180015890216554157300
load13421165335528713521622
domContentLoaded13191143334228313071536
domInteractive3821271343874
firstPaint260881500206297340
backgroundConnect149530312469179124043826
firstReactRender25184962639
initialActions103113
loadScripts1096945311123311011285
setupStore1674181933
numNetworkReqs23210943570266350
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2172162191218219
srpButtonToSrpForm9693101399101
confirmSrpToPwForm22212202222
pwFormToMetricsScreen15151501515
metricsToWalletReadyScreen16151601616
doneButtonToHomeScreen1097102911795911441179
openAccountMenuToAccountListLoaded2617249327099926932709
total4083400541775941094177
Onboarding New WalletcreateWalletToSocialScreen2182172191218219
srpButtonToPwForm1061061070107107
createPwToRecoveryScreen888088
skipBackupToMetricsScreen39374224042
agreeButtonToOnboardingSuccess16151711617
doneButtonToAssetList938512125431611941254
total1325897164431915811644
Asset DetailsassetClickToPriceChart101971064106106
total101971064106106
Solana Asset DetailsassetClickToPriceChart61507297172
total61507297172
Import Srp HomeloginToHomeScreen2220220022391822372239
openAccountMenuAfterLogin47385454954
homeAfterImportWithNewWallet9335928193774093779377
total116451152711790941163911790
Send TransactionsopenSendPageFromHome22202522225
selectTokenToSendFormLoaded24213032530
reviewTransactionToConfirmationPage85483786811866868
total90388492616916926
SwapopenSwapPageFromHome503170176970
fetchAndDisplaySwapQuotes269526932697226972697
total2737272627641627302764
🌐 Dapp Page Load Benchmarks

Current Commit: 97a55c6 | Date: 3/30/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±41ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 730ms (±38ms) 🟢 | historical mean value: 725ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 85ms (±10ms) 🟢 | historical mean value: 85ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 41ms 1.01s 1.35s 1.07s 1.35s
domContentLoaded 730ms 38ms 705ms 1.02s 757ms 1.02s
firstPaint 85ms 10ms 68ms 168ms 92ms 168ms
firstContentfulPaint 85ms 10ms 68ms 168ms 92ms 168ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 101 Bytes (0%)
  • ui: 591 Bytes (0.01%)
  • common: 20 Bytes (0%)

@gauthierpetetin gauthierpetetin marked this pull request as ready for review March 31, 2026 08:22
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Mar 31, 2026
@seaona

seaona commented Mar 31, 2026

Copy link
Copy Markdown
Member

The fix works fine 🙌

fix-reload.mov

@DDDDDanica

Copy link
Copy Markdown
Contributor

LGTM !

@sonarqubecloud

sonarqubecloud Bot commented Apr 2, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
66.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@metamaskbotv2

metamaskbotv2 Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor
Builds ready [81493dc]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): 8125dd2 | Date: 6/5/58221 | Pipeline: 23894070436 | Baseline logs

Interaction Benchmarks
Benchmarkchrome-browserify
loadNewAccount🟢 [Show logs]
confirmTx🟢 [Show logs]
bridgeUserActions🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • bridgeUserActions/bridge_load_page: +13%
Startup Benchmarks
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/initialActions: +43%
  • startupPowerUserHome/domInteractive: +11%
  • startupPowerUserHome/backgroundConnect: -17%
  • startupPowerUserHome/numNetworkReqs: -12%
  • startupPowerUserHome/firstPaint: +15%
  • startupPowerUserHome/setupStore: +10%
  • startupPowerUserHome/numNetworkReqs: +29%
  • startupStandardHome/initialActions: +43%
  • startupPowerUserHome/domInteractive: -13%
  • startupPowerUserHome/setupStore: +12%
  • startupStandardHome/initialActions: +11%
  • startupStandardHome/setupStore: -27%
  • startupPowerUserHome/backgroundConnect: +15%
User Journey Benchmarks
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟢 [Show logs]
solanaAssetDetails🟢 [Show logs]
importSrpHome🟢 [Show logs]
sendTransactions🟢 [Show logs]
swap🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/metricsToWalletReadyScreen: +19%
  • onboardingImportWallet/doneButtonToHomeScreen: -77%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +51%
  • onboardingImportWallet/total: -38%
  • onboardingNewWallet/doneButtonToAssetList: -25%
  • onboardingNewWallet/total: -21%
  • assetDetails/assetClickToPriceChart: -25%
  • assetDetails/total: -25%
  • solanaAssetDetails/assetClickToPriceChart: -39%
  • solanaAssetDetails/total: -39%
  • importSrpHome/openAccountMenuAfterLogin: -33%
  • importSrpHome/homeAfterImportWithNewWallet: -46%
  • importSrpHome/total: -42%
  • swap/openSwapPageFromHome: -84%
  • swap/fetchAndDisplaySwapQuotes: +37%
  • swap/total: +16%
🌐 Dapp Page Load Benchmarks

Current Commit: 81493dc | Date: 4/2/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±39ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 725ms (±37ms) 🟢 | historical mean value: 730ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 85ms (±14ms) 🟢 | historical mean value: 85ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 39ms 1.00s 1.31s 1.07s 1.31s
domContentLoaded 725ms 37ms 700ms 999ms 755ms 999ms
firstPaint 85ms 14ms 68ms 196ms 96ms 196ms
firstContentfulPaint 85ms 14ms 68ms 196ms 96ms 196ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 101 Bytes (0%)
  • ui: 589 Bytes (0.01%)
  • common: 20 Bytes (0%)

@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Apr 2, 2026
@gauthierpetetin gauthierpetetin added this pull request to the merge queue Apr 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 2, 2026
@gauthierpetetin gauthierpetetin added this pull request to the merge queue Apr 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 2, 2026
@gauthierpetetin gauthierpetetin added this pull request to the merge queue Apr 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 2, 2026
@gauthierpetetin gauthierpetetin added this pull request to the merge queue Apr 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 2, 2026
@gauthierpetetin gauthierpetetin added this pull request to the merge queue Apr 2, 2026
Merged via the queue into main with commit ace1318 Apr 2, 2026
206 of 207 checks passed
@gauthierpetetin gauthierpetetin deleted the fix/29151-error-try-again-reload branch April 2, 2026 15:26
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 2, 2026
@metamaskbot metamaskbot added the release-13.26.0 Issue or pull request that will be included in release 13.26.0 label Apr 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.26.0 Issue or pull request that will be included in release 13.26.0 size-S team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Bug]: Error Screen - Clicking Try again with the popup view resets my browser inside the popup screen with a strange result

5 participants