Skip to content

fix: clear stale keyring to prevent USB reconnect flapping#66

Open
BitHighlander wants to merge 2 commits intodevelopfrom
fix/usb-reconnect-flapping
Open

fix: clear stale keyring to prevent USB reconnect flapping#66
BitHighlander wants to merge 2 commits intodevelopfrom
fix/usb-reconnect-flapping

Conversation

@BitHighlander
Copy link
Copy Markdown
Collaborator

Summary

  • On app startup, WebUSB pairing fails with "cannot connect an already-connected connection" and retries every 5s until a physical detach/attach cycle
  • Root cause: initializeWallet() doesn't clear the keyring before retrying, so the previous failed attempt's transport still has usbDevice.opened = true
  • Fix: call keyring.removeAll() at the top of initializeWallet() to close stale transports before pairing

Test plan

  • Cold start with KeepKey plugged in — should pair on first attempt without "already-connected" errors
  • Verify detach/attach still works correctly after the fix
  • Verify retry loop (when device is claimed by another app) still schedules retries

…ping

When initializeWallet() is called on retry, the keyring may still hold
a transport from the previous failed attempt with usbDevice.opened=true.
WebUSB rejects with "cannot connect an already-connected connection" and
the device loops between connected_unpaired retries until a physical
detach/attach cycle resets the state.

Call keyring.removeAll() at the top of initializeWallet() to close any
stale transports before attempting to pair.
LIBUSB_TRANSFER_ERROR from a previous session persisted in the setup
wizard error banner after disconnect/reconnect. Clear setupError when
device state transitions to needs_init or ready.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant