Skip to content

Commit 5c06872

Browse files
committed
fix(transport): rework usb disconnected error handling
1 parent 2c25657 commit 5c06872

File tree

1 file changed

+5
-6
lines changed
  • packages/transport/src/api

1 file changed

+5
-6
lines changed

packages/transport/src/api/usb.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -500,22 +500,21 @@ export class UsbApi extends AbstractApi {
500500
return [hidDevices, nonHidDevices];
501501
}
502502

503+
// old bridge narrows multiple different errors to "device was disconnected" error.
503504
// https://github.com/trezor/trezord-go/blob/db03d99230f5b609a354e3586f1dfc0ad6da16f7/usb/libusb.go#L545
505+
// I am not sure if this is correct so at this point we only narrow disconnected error from node-usb and webusb
504506
private handleReadWriteError(err: Error) {
505507
if (
506508
[
507509
// node usb
508-
// 'LIBUSB_TRANSFER_ERROR',
509-
// 'LIBUSB_ERROR_PIPE',
510-
// 'LIBUSB_ERROR_IO',
511-
// 'LIBUSB_ERROR_OTHER',
512-
513510
'LIBUSB_ERROR_NO_DEVICE',
514511
// web usb
515-
ERRORS.INTERFACE_DATA_TRANSFER,
516512
'The device was disconnected.',
517513
].some(disconnectedErr => err.message.includes(disconnectedErr))
518514
) {
515+
// make sure that local descriptors are updated and higher layers are notified
516+
this.enumerate();
517+
519518
return this.error({ error: ERRORS.DEVICE_DISCONNECTED_DURING_ACTION });
520519
}
521520

0 commit comments

Comments
 (0)