File tree 1 file changed +8
-2
lines changed
packages/hardware-ledger/src
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -377,12 +377,18 @@ export class LedgerKeyAgent extends KeyAgentBase {
377
377
}
378
378
379
379
private static attachDisconnectionCleanupHandler ( transport : LedgerTransportType ) {
380
- const onDisconnect = ( ) => {
380
+ const onDisconnect = async ( ) => {
381
381
transport . off ( 'disconnect' , onDisconnect ) ;
382
382
this . deviceConnections = this . deviceConnections . filter (
383
383
( { deviceConnection } ) => deviceConnection . transport !== transport
384
384
) ;
385
- void transport . close ( ) ;
385
+
386
+ try {
387
+ await transport . close ( ) ;
388
+ } catch {
389
+ // hw-transport-webusb also adds a disconnect event listener while creating a Ledger transport,
390
+ // so calling close() method will throw an error, since the device is already disconnected
391
+ }
386
392
} ;
387
393
transport . on ( 'disconnect' , onDisconnect ) ;
388
394
}
You can’t perform that action at this time.
0 commit comments