fix: handle transient BLE errors during Ledger app switch and simplify HW retry logic#26798
Conversation
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These are internal refactoring changes that improve Bluetooth connection reliability without changing user-facing behavior. The SmokeAccounts tag is selected because it covers "adding QR-based hardware wallet accounts" according to the tag description, and hardware wallet functionality is part of account management flows. The changes are well-covered by unit tests (all updated in this PR), and the risk is medium because while the changes are internal refactoring, they affect critical hardware wallet connection flows that could impact users connecting Ledger devices. However, there are no dedicated E2E tests for Ledger connection flows in the test suite, so SmokeAccounts provides the closest coverage for hardware wallet account-related functionality. Performance Test Selection: |
| const CONNECTION_RESTART_LIMIT = 5; | ||
| const MAX_DISCONNECT_RETRIES = 3; | ||
| const RETRY_DELAY_MS = 1000; | ||
| const RETRY_DELAY_MS = 2000; |
There was a problem hiding this comment.
Just to be a bit on the safer side considering the randomness of BLE readiness times. I know this isn't a perfect solution (good catch), I might even revert it in the first implementation PR if I find it's stable enough.
Description
Part "4.5.1" of the hardware wallet connection & error management overhaul. This is a small follow up PR and does not introduce user facing changes.
Will close:
Final implementation will look like this (Figma designs):

Reference feature branch: #25519
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
No manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes core hardware-wallet connection/retry behavior (including BLE reconnection timing and which errors are retried), which could impact Ledger connection reliability and error recovery paths.
Overview
Improves Ledger BLE readiness checks by retrying
ensureDeviceReadyon a broader set of transient BLE errors (e.g., disconnects during app switch, pairing-related failures) and increasing the retry backoff delay.Simplifies the hardware-wallet retry path by removing generic "retry last operation" tracking and standardizing retries around
retryEnsureDeviceReady(wired throughHardwareWalletProvider/HardwareWalletBottomSheet), while dropping the now-unusedclearErrorhandler fromuseDeviceEventHandlers.Tightens adapter connection failure behavior/tests to ensure connect errors clear adapter connection state and propagate thrown values consistently.
Written by Cursor Bugbot for commit 2e64c8a. This will update automatically on new commits. Configure here.