Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/hdwallet-keepkey-nodewebusb/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ export class TransportDelegate implements keepkey.TransportDelegate {
async readChunk(debugLink?: boolean): Promise<Uint8Array> {
const result = await this.usbDevice.transferIn(debugLink ? 2 : 1, keepkey.SEGMENT_SIZE + 1);

if (result.status === "stall" && result.data !== undefined) {
await this.usbDevice.clearHalt("out", debugLink ? 2 : 1);
if (result.status === "stall") {
// Reset the halt on the IN pipe we just read (not OUT), then surface a
// retryable error -- a stalled transfer's buffer is not a valid packet.
await this.usbDevice.clearHalt("in", debugLink ? 2 : 1);
throw new Error("bad read");
} else if (result.status !== "ok" || result.data === undefined) {
throw new Error("bad read");
}
Expand Down
5 changes: 4 additions & 1 deletion packages/hdwallet-keepkey-webusb/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export class TransportDelegate implements keepkey.TransportDelegate {
const { status, data } = await this.usbDevice.transferIn(debugLink ? 2 : 1, keepkey.SEGMENT_SIZE + 1);

if (status === "stall") {
await this.usbDevice.clearHalt("out", debugLink ? 2 : 1);
// Reset the halt on the IN pipe we just read (not OUT), then surface a
// retryable error -- a stalled transfer's buffer is not a valid packet.
await this.usbDevice.clearHalt("in", debugLink ? 2 : 1);
throw new Error("bad read");
}

if (data === undefined) throw new Error("bad read");
Expand Down
Loading