fix(ui): reload extension safely from error Try again in popup#41364
Merged
Conversation
- 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
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. |
Contributor
Builds ready [97a55c6]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
Member
|
The fix works fine 🙌 fix-reload.mov |
DDDDDanica
approved these changes
Apr 1, 2026
Contributor
|
LGTM ! |
|
Contributor
Builds ready [81493dc]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 0 warn · 🔴 0 fail)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
itsyoboieltr
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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
requestSafeReloadin the service worker: persistence is flushed,runtime.reload()is scheduled after a short delay, andreloadExtensionFromUicallsrequestSafeReloadthenwindow.close()so the window is dismissed before reload. Error page and API error handler Try again actions use the shared helper instead of callingbrowser.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
yarn startand open it.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
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.
requestSafeReloadnow delaysruntime.reload()slightly after flushing pending persistence writes, and UI surfaces (Error Page and Shield API error handler) route “Try again” through a newreloadExtensionFromUihelper that callsrequestSafeReloadthenwindow.close(), with a fallback to directruntime.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.