diff --git a/src/helpers/deviceAccess.js b/src/helpers/deviceAccess.js index 05d9ced3..9104b769 100644 --- a/src/helpers/deviceAccess.js +++ b/src/helpers/deviceAccess.js @@ -4,6 +4,7 @@ import throttle from 'lodash/throttle' import type Transport from '@ledgerhq/hw-transport' import TransportNodeHid from '@ledgerhq/hw-transport-node-hid' import { DisconnectedDevice, CantOpenDevice } from 'config/errors' +import { retry } from './promise' // all open to device must use openDevice so we can prevent race conditions // and guarantee we do one device access at a time. It also will handle the .close() @@ -39,7 +40,7 @@ export const withDevice: WithDevice = devicePath => job => { busy = true refreshBusyUIState() try { - const t = await TransportNodeHid.open(devicePath).catch(mapError) + const t = await retry(() => TransportNodeHid.open(devicePath), { maxRetry: 1 }).catch(mapError).catch(mapError) t.setDebugMode(logger.apdu) try { const res = await job(t).catch(mapError)