diff --git a/.changeset/fuzzy-cats-enjoy.md b/.changeset/fuzzy-cats-enjoy.md new file mode 100644 index 000000000000..dd72b4daa012 --- /dev/null +++ b/.changeset/fuzzy-cats-enjoy.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/hw-transport-webhid": patch +--- + +Fix invalid channel when using multiple apps diff --git a/libs/ledgerjs/packages/hw-transport-webhid/src/TransportWebHID.ts b/libs/ledgerjs/packages/hw-transport-webhid/src/TransportWebHID.ts index 0ddb4ebdea0d..85031dde2a71 100644 --- a/libs/ledgerjs/packages/hw-transport-webhid/src/TransportWebHID.ts +++ b/libs/ledgerjs/packages/hw-transport-webhid/src/TransportWebHID.ts @@ -212,8 +212,19 @@ export default class TransportWebHID extends Transport { let acc; while (!(result = framing.getReducedResult(acc))) { - const buffer = await this.read(); - acc = framing.reduceResponse(acc, buffer); + try { + const buffer = await 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 + continue; + } + + throw e; + } } log("apdu", "<= " + result.toString("hex"));