Skip to content

fix(nodehid): use async read() so device Cancel can dispatch#54

Merged
BitHighlander merged 1 commit into
masterfrom
fix/hid-nonblocking-read
Jul 13, 2026
Merged

fix(nodehid): use async read() so device Cancel can dispatch#54
BitHighlander merged 1 commit into
masterfrom
fix/hid-nonblocking-read

Conversation

@BitHighlander

Copy link
Copy Markdown
Collaborator

On the HID transport, TransportDelegate.readChunk() used node-hid readSync(), which blocks the JS event loop for the entire time the device waits for a button press. Because the loop is frozen, no concurrent RPC handler (e.g. cancelDeviceSigningwallet.cancel()) can dispatch until signing finishes — so sending an on-device Cancel was impossible on HID. This is the root cause of the vault swap flow's Cancel button not aborting the device.

Fix: read via node-hid's async read(callback), which runs on a background thread and keeps the event loop free. Same one-report-per-call semantics; new Uint8Array(number[]) unchanged.

WebUSB and emulator transports were already non-blocking, so this only affected the HID fallback.

readSync() blocks the JS event loop while the device waits for a button
press, which prevented any concurrent RPC (e.g. cancelDeviceSigning) from
running until signing completed. On the HID transport this made on-device
Cancel impossible (notably the swap flow's Cancel button). node-hid's
async read() runs on a background thread, keeping the loop free.
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hdwallet-sandbox Ready Ready Preview, Comment Jul 13, 2026 8:08pm

Request Review

@BitHighlander BitHighlander merged commit 089e4ba into master Jul 13, 2026
5 checks passed
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