Skip to content

Commit

Permalink
fix(transport): usb - write timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mroz22 committed Feb 4, 2025
1 parent 80e7d3e commit eb781d8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/transport/src/api/usb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,15 @@ export class UsbApi extends AbstractApi {
const newArray = new Uint8Array(this.chunkSize);
newArray.set(new Uint8Array(buffer));

const timeout = setTimeout(() => {
this.logger?.debug('usb: device.transfer out take suspiciously long. timing out.');
device?.reset();
}, 1000);

try {
// https://wicg.github.io/webusb/#ref-for-dom-usbdevice-transferout
this.logger?.debug('usb: device.transferOut');

const result = await this.abortableMethod(
() =>
device.transferOut(
Expand All @@ -250,6 +256,8 @@ export class UsbApi extends AbstractApi {
return this.success(undefined);
} catch (err) {
return this.handleReadWriteError(err);
} finally {
clearTimeout(timeout);
}
}

Expand Down

0 comments on commit eb781d8

Please sign in to comment.