release(runway): cherry-pick fix(hardware-wallets): bound stuck account-creation spinner with device-read timeout cp-13.42.0 - #45053
Merged
HowardBraham merged 1 commit intoJul 30, 2026
Conversation
…nt-creation spinner with device-read timeout cp-13.42.0 (#45048) ## **Description** `unlockHardwareWalletAccount` calls `keyring.createAccounts`, which derives the account address from the hardware device. When the device is locked or unresponsive, that device read can hang indefinitely. Every other device-reading method (`connectHardware`, `checkHardwareStatus`, `getLedgerPublicKey`, …) runs on the lock-free `deviceRead: true` path in `#withKeyringForDevice`, which wraps the call in a `Promise.race` against `HARDWARE_DEVICE_READ_TIMEOUT_MS` so a wedged device rejects with an actionable error. `unlockHardwareWalletAccount` did not. `createAccounts` mutates vault state, so it cannot use the lock-free `deviceRead` path (the `restrictKeyringForDeviceRead` facade intentionally omits `createAccounts` along with every other mutating method). It must run under the controller lock — but it still does device I/O that can hang, and there was no timeout backstop. As a result, a hung device during account creation: 1. Never settled `submitRequestToBackground('unlockHardwareWalletAccount', …)`, so the `unlockHardwareWalletAccounts` thunk never reached `hideLoadingIndication()` → `appState.isLoading` stayed `true` → the global `<Loading />` overlay in `ui/pages/routes/routes.component.tsx` spun forever. 2. Held the controller operation mutex across the hang, wedging other locked keyring operations until the browser restarted. The user-facing symptom: after pressing **Unlock** on the "Select an account" page at `/new-account/connect`, the spinner never resolved and the UX appeared stuck. **Solution:** wrap the create operation in the same `HARDWARE_DEVICE_READ_TIMEOUT_MS` `Promise.race` backstop used by `#withKeyringForDevice`'s device-read branch. On timeout the call rejects with an actionable error, which propagates back through the thunk so `hideLoadingIndication()` runs, the spinner clears, and the error surfaces to the user. The abandoned create operation's eventual rejection is observed (`.catch`) so it never surfaces as an unhandled rejection — mirroring the existing device-read path. ## **Changelog** CHANGELOG entry: Fixed a bug where connecting a hardware wallet account could leave the loading spinner stuck forever if the device stopped responding. ## **Related issues** Fixes: TBD ## **Manual testing steps** 1. Build the extension (`yarn start` or `yarn build:test`). 2. Go to **Add account → Add hardware wallet** (the `/new-account/connect` route) and connect a Ledger or Trezor. 3. On the "Select an account" page, select one or more accounts and press **Unlock**. 4. With the device responsive, confirm the spinner shows briefly and the account imports successfully. 5. Repeat, but leave the device locked / disconnected / unresponsive after pressing **Unlock**. 6. Verify the spinner no longer spins forever — after the timeout it dismisses and an actionable "Hardware wallet account creation timed out" error is shown, and the rest of the wallet remains usable. ## **Screenshots/Recordings** <!-- ### **Before** ### **After** --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
|
Contributor
Builds ready [99246fd]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 10 warn · 🔴 2 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
HowardBraham
approved these changes
Jul 30, 2026
HowardBraham
enabled auto-merge (squash)
July 30, 2026 19:32
Contributor
|
No release label on PR. Adding release label release-13.42.0 on PR, as PR was cherry-picked in branch 13.42.0. |
This branch was previously deployed
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
unlockHardwareWalletAccountcallskeyring.createAccounts, whichderives the account address from the hardware device. When the device is
locked or unresponsive, that device read can hang indefinitely.
Every other device-reading method (
connectHardware,checkHardwareStatus,getLedgerPublicKey, …) runs on the lock-freedeviceRead: truepath in#withKeyringForDevice, which wraps the callin a
Promise.raceagainstHARDWARE_DEVICE_READ_TIMEOUT_MSso awedged device rejects with an actionable error.
unlockHardwareWalletAccountdid not.createAccountsmutates vault state, so it cannot use the lock-freedeviceReadpath (therestrictKeyringForDeviceReadfacadeintentionally omits
createAccountsalong with every other mutatingmethod). It must run under the controller lock — but it still does
device I/O that can hang, and there was no timeout backstop. As a
result, a hung device during account creation:
submitRequestToBackground('unlockHardwareWalletAccount', …), so theunlockHardwareWalletAccountsthunk never reachedhideLoadingIndication()→appState.isLoadingstayedtrue→ theglobal
<Loading />overlay inui/pages/routes/routes.component.tsxspun forever.
locked keyring operations until the browser restarted.
The user-facing symptom: after pressing Unlock on the "Select an
account" page at
/new-account/connect, the spinner never resolved andthe UX appeared stuck.
Solution: wrap the create operation in the same
HARDWARE_DEVICE_READ_TIMEOUT_MSPromise.racebackstop used by#withKeyringForDevice's device-read branch. On timeout the callrejects with an actionable error, which propagates back through the
thunk so
hideLoadingIndication()runs, the spinner clears, and theerror surfaces to the user. The abandoned create operation's eventual
rejection is observed (
.catch) so it never surfaces as an unhandledrejection — mirroring the existing device-read path.
Changelog
CHANGELOG entry: Fixed a bug where connecting a hardware wallet account
could leave the loading spinner stuck forever if the device stopped
responding.
Related issues
Fixes: TBD
Manual testing steps
yarn startoryarn build:test)./new-account/connectroute) and connect a Ledger or Trezor.press Unlock.
account imports successfully.
after pressing Unlock.
dismisses and an actionable "Hardware wallet account creation timed out"
error is shown, and the rest of the wallet remains usable.
Screenshots/Recordings
Pre-merge author checklist
Docs and MetaMask
Extension Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Made with Cursor
Co-authored-by: Cursor cursoragent@cursor.com d90d1e7