From d28b29cb608f1b33e89f677220f42765c04d43b5 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Thu, 28 Aug 2025 15:52:48 +0100 Subject: [PATCH 1/3] fix: deviceId method --- src/helpers/deviceId.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/deviceId.ts b/src/helpers/deviceId.ts index 1282e1b79..628a5bcda 100644 --- a/src/helpers/deviceId.ts +++ b/src/helpers/deviceId.ts @@ -1,5 +1,5 @@ import { getDeviceId } from "@mongodb-js/device-id"; -import * as nodeMachineId from "node-machine-id"; +import nodeMachineId from "node-machine-id"; import type { LoggerBase } from "../common/logger.js"; import { LogId } from "../common/logger.js"; From d2523b8e5d306ba3985c8082b04bf867fcb9abeb Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Thu, 28 Aug 2025 16:06:09 +0100 Subject: [PATCH 2/3] fix: adapt deviceId import to cjs and esm --- src/helpers/deviceId.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/helpers/deviceId.ts b/src/helpers/deviceId.ts index 628a5bcda..1978fdbfe 100644 --- a/src/helpers/deviceId.ts +++ b/src/helpers/deviceId.ts @@ -1,8 +1,9 @@ import { getDeviceId } from "@mongodb-js/device-id"; -import nodeMachineId from "node-machine-id"; import type { LoggerBase } from "../common/logger.js"; import { LogId } from "../common/logger.js"; +// Import node-machine-id based on the module system + export const DEVICE_ID_TIMEOUT = 3000; export class DeviceId { @@ -17,7 +18,11 @@ export class DeviceId { private constructor(logger: LoggerBase, timeout: number = DEVICE_ID_TIMEOUT) { this.logger = logger; this.timeout = timeout; - this.getMachineId = (): Promise => nodeMachineId.machineId(true); + this.getMachineId = async (): Promise => { + const nodeMachineId = await import("node-machine-id"); + const machineId = nodeMachineId.default?.machineId || nodeMachineId.machineId; + return machineId(true); + }; this.abortController = new AbortController(); this.deviceIdPromise = DeviceId.UnknownDeviceId; From a796173b4b91c36640e4c9e17d899487c103ced1 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Thu, 28 Aug 2025 16:07:11 +0100 Subject: [PATCH 3/3] clean up --- src/helpers/deviceId.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/helpers/deviceId.ts b/src/helpers/deviceId.ts index 1978fdbfe..758a1ae20 100644 --- a/src/helpers/deviceId.ts +++ b/src/helpers/deviceId.ts @@ -2,8 +2,6 @@ import { getDeviceId } from "@mongodb-js/device-id"; import type { LoggerBase } from "../common/logger.js"; import { LogId } from "../common/logger.js"; -// Import node-machine-id based on the module system - export const DEVICE_ID_TIMEOUT = 3000; export class DeviceId {