diff --git a/apps/ledger-live-desktop/src/renderer/hooks/useListenToHidDevices.ts b/apps/ledger-live-desktop/src/renderer/hooks/useListenToHidDevices.ts index 64708532fc6..e4f42d5d029 100644 --- a/apps/ledger-live-desktop/src/renderer/hooks/useListenToHidDevices.ts +++ b/apps/ledger-live-desktop/src/renderer/hooks/useListenToHidDevices.ts @@ -2,7 +2,11 @@ import { useEffect } from "react"; import { useDispatch } from "react-redux"; import { Subscription, Observable } from "rxjs"; import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; -import { useDeviceManagementKit, DeviceManagementKitTransport } from "@ledgerhq/live-dmk"; +import { + useDeviceManagementKit, + DeviceManagementKitTransport, + useDeviceSessionRefresherToggle, +} from "@ledgerhq/live-dmk"; import { DeviceModelId } from "@ledgerhq/types-devices"; import { IPCTransport } from "~/renderer/IPCTransport"; import { addDevice, removeDevice, resetDevices } from "~/renderer/actions/devices"; @@ -13,6 +17,8 @@ export const useListenToHidDevices = () => { const deviceManagementKit = useDeviceManagementKit(); + useDeviceSessionRefresherToggle(ldmkFeatureFlag?.enabled ?? false); + useEffect(() => { let sub: Subscription; diff --git a/libs/ledger-live-common/package.json b/libs/ledger-live-common/package.json index 81ec3edb20b..9026a99b81a 100644 --- a/libs/ledger-live-common/package.json +++ b/libs/ledger-live-common/package.json @@ -182,6 +182,7 @@ "@ledgerhq/live-config": "workspace:^", "@ledgerhq/live-countervalues": "workspace:^", "@ledgerhq/live-countervalues-react": "workspace:^", + "@ledgerhq/live-dmk": "workspace:^", "@ledgerhq/live-env": "workspace:^", "@ledgerhq/live-hooks": "workspace:*", "@ledgerhq/live-network": "workspace:^", diff --git a/libs/ledger-live-common/src/hw/deviceAccess.ts b/libs/ledger-live-common/src/hw/deviceAccess.ts index 553465e8acf..1db055231e0 100644 --- a/libs/ledger-live-common/src/hw/deviceAccess.ts +++ b/libs/ledger-live-common/src/hw/deviceAccess.ts @@ -1,4 +1,4 @@ -import { Observable, throwError, timer } from "rxjs"; +import { Observable, of, throwError, timer } from "rxjs"; import { retryWhen, mergeMap, catchError } from "rxjs/operators"; import Transport from "@ledgerhq/hw-transport"; import { @@ -17,6 +17,7 @@ import { } from "@ledgerhq/errors"; import { LocalTracer, TraceContext, trace } from "@ledgerhq/logs"; import { getEnv } from "@ledgerhq/live-env"; +import { isAllowedWithDeviceErrorDmk } from "@ledgerhq/live-dmk"; import { open, close } from "."; const LOG_TYPE = "hw"; @@ -32,6 +33,10 @@ const initialErrorRemapping = (error: unknown, context?: TraceContext) => { } } + if (isAllowedWithDeviceErrorDmk(error)) { + return of(undefined); + } + trace({ type: LOG_TYPE, message: `Initial error remapping: ${error}`, diff --git a/libs/live-dmk/src/config/errors.ts b/libs/live-dmk/src/config/errors.ts index 369eb4eb907..6972a7b70d2 100644 --- a/libs/live-dmk/src/config/errors.ts +++ b/libs/live-dmk/src/config/errors.ts @@ -8,3 +8,11 @@ export const isAllowedOnboardingStatePollingErrorDmk = (error: unknown): boolean return false; }; + +export const isAllowedWithDeviceErrorDmk = (error: unknown): boolean => { + if (error) { + return error instanceof DeviceBusyError || error instanceof WebHidSendReportError; + } + + return false; +}; diff --git a/libs/live-dmk/src/hooks/useDeviceSessionRefresherToggle.tsx b/libs/live-dmk/src/hooks/useDeviceSessionRefresherToggle.tsx index 148b66b6018..6aacf02cc6f 100644 --- a/libs/live-dmk/src/hooks/useDeviceSessionRefresherToggle.tsx +++ b/libs/live-dmk/src/hooks/useDeviceSessionRefresherToggle.tsx @@ -16,7 +16,8 @@ export const useDeviceSessionRefresherToggle = (enabled: boolean) => { if (sessionId.current) { sdk.toggleDeviceSessionRefresher({ sessionId: sessionId.current, - enabled: true, + // TODO: remove this once we have a proper way to disable the refresher + enabled: false, }); } @@ -36,7 +37,8 @@ export const useDeviceSessionRefresherToggle = (enabled: boolean) => { if (sessionId.current) { sdk.toggleDeviceSessionRefresher({ sessionId: sessionId.current, - enabled: true, + // TODO: remove this once we have a proper way to disable the refresher + enabled: false, }); } }; @@ -48,7 +50,8 @@ export const useDeviceSessionRefresherToggle = (enabled: boolean) => { if (sessionId.current) { sdk.toggleDeviceSessionRefresher({ sessionId: sessionId.current, - enabled: true, + // TODO: remove this once we have a proper way to disable the refresher + enabled: false, }); } }, [sdk]); diff --git a/libs/live-dmk/src/index.ts b/libs/live-dmk/src/index.ts index f50f212d4cd..0724234c537 100644 --- a/libs/live-dmk/src/index.ts +++ b/libs/live-dmk/src/index.ts @@ -1,3 +1,6 @@ export { DeviceManagementKitTransport } from "./transport/DeviceManagementKitTransport"; export * from "./hooks"; -export { isAllowedOnboardingStatePollingErrorDmk } from "./config/errors"; +export { + isAllowedOnboardingStatePollingErrorDmk, + isAllowedWithDeviceErrorDmk, +} from "./config/errors"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b2e41fea958..bb1c14780e4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4095,6 +4095,9 @@ importers: '@ledgerhq/live-countervalues-react': specifier: workspace:^ version: link:../live-countervalues-react + '@ledgerhq/live-dmk': + specifier: workspace:^ + version: link:../live-dmk '@ledgerhq/live-env': specifier: workspace:^ version: link:../env