File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { getDeviceId } from "@mongodb-js/device-id" ;
2
- import nodeMachineId from "node-machine-id" ;
3
2
import type { LoggerBase } from "../common/logger.js" ;
4
3
import { LogId } from "../common/logger.js" ;
5
4
5
+ // Import node-machine-id based on the module system
6
+
6
7
export const DEVICE_ID_TIMEOUT = 3000 ;
7
8
8
9
export class DeviceId {
@@ -17,7 +18,11 @@ export class DeviceId {
17
18
private constructor ( logger : LoggerBase , timeout : number = DEVICE_ID_TIMEOUT ) {
18
19
this . logger = logger ;
19
20
this . timeout = timeout ;
20
- this . getMachineId = ( ) : Promise < string > => nodeMachineId . machineId ( true ) ;
21
+ this . getMachineId = async ( ) : Promise < string > => {
22
+ const nodeMachineId = await import ( "node-machine-id" ) ;
23
+ const machineId = nodeMachineId . default ?. machineId || nodeMachineId . machineId ;
24
+ return machineId ( true ) ;
25
+ } ;
21
26
this . abortController = new AbortController ( ) ;
22
27
23
28
this . deviceIdPromise = DeviceId . UnknownDeviceId ;
You can’t perform that action at this time.
0 commit comments