fix(nodehid): use async read() so device Cancel can dispatch#54
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On the HID transport,
TransportDelegate.readChunk()used node-hidreadSync(), 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.cancelDeviceSigning→wallet.cancel()) can dispatch until signing finishes — so sending an on-deviceCancelwas 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.