Skip to content

Commit 251414c

Browse files
committed
fix
1 parent ff80ff5 commit 251414c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/helpers/deviceId.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export const DEVICE_ID_TIMEOUT = 3000;
1818
* ```
1919
*/
2020
export async function getDeviceIdForConnection(): Promise<string> {
21+
const controller = new AbortController();
22+
const timeoutId = setTimeout(() => controller.abort(), DEVICE_ID_TIMEOUT);
23+
2124
try {
2225
const deviceId = await getDeviceId({
2326
getMachineId: () => nodeMachineId.machineId(true),
@@ -34,10 +37,12 @@ export async function getDeviceIdForConnection(): Promise<string> {
3437
break;
3538
}
3639
},
37-
abortSignal: abortSignal || controller.signal,
40+
abortSignal: controller.signal,
3841
});
42+
clearTimeout(timeoutId);
3943
return deviceId;
4044
} catch (error) {
45+
clearTimeout(timeoutId);
4146
logger.debug(LogId.telemetryDeviceIdFailure, "deviceId", `Failed to get device ID: ${String(error)}`);
4247
return "unknown";
4348
}

0 commit comments

Comments
 (0)