From 20297b6c2b2a0e8dc8843c700bbffb1b23549126 Mon Sep 17 00:00:00 2001 From: Thibaut Boustany Date: Mon, 30 Jul 2018 17:49:07 +0200 Subject: [PATCH] `retry` restored to fix comm error on app change --- src/helpers/deviceAccess.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)