-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/ledger-invalid-channel' into tmp/20241213
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
diff --git a/node_modules/@ledgerhq/hw-transport-webhid/lib-es/TransportWebHID.js b/node_modules/@ledgerhq/hw-transport-webhid/lib-es/TransportWebHID.js | ||
index 8246e08..b79c4c0 100644 | ||
--- a/node_modules/@ledgerhq/hw-transport-webhid/lib-es/TransportWebHID.js | ||
+++ b/node_modules/@ledgerhq/hw-transport-webhid/lib-es/TransportWebHID.js | ||
@@ -107,8 +107,19 @@ class TransportWebHID extends Transport { | ||
let result; | ||
let acc; | ||
while (!(result = framing.getReducedResult(acc))) { | ||
- const buffer = yield this.read(); | ||
- acc = framing.reduceResponse(acc, buffer); | ||
+ try { | ||
+ const buffer = yield this.read(); | ||
+ acc = framing.reduceResponse(acc, buffer); | ||
+ } catch (e) { | ||
+ if (e instanceof TransportError && e.id === "InvalidChannel") { | ||
+ // this can happen if the device is connected | ||
+ // on a different channel (like another app) | ||
+ // in this case we just filter out the event | ||
+ console.log(e); | ||
+ continue; | ||
+ } | ||
+ throw e; | ||
+ } | ||
} | ||
log("apdu", "<= " + result.toString("hex")); | ||
return result; |