Skip to content

Commit f8de877

Browse files
committed
squashed commits
1 parent c3f0928 commit f8de877

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/helpers/connectionOptions.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,8 @@ export async function setAppNameParamIfMissing({
3030
return connectionStringUrl.toString();
3131
}
3232

33-
// Get deviceId if not provided
34-
let deviceId = components.deviceId;
35-
if (!deviceId) {
36-
deviceId = await getDeviceIdForConnection();
37-
}
38-
39-
// Get clientName if not provided
40-
let clientName = components.clientName;
41-
if (!clientName) {
42-
clientName = "unknown";
43-
}
33+
const deviceId = components.deviceId || (await getDeviceIdForConnection());
34+
const clientName = components.clientName || "unknown";
4435

4536
// Build the extended appName format: appName--deviceId--clientName
4637
const extendedAppName = `${components.appName}--${deviceId}--${clientName}`;

src/helpers/deviceId.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export const DEVICE_ID_TIMEOUT = 3000;
1818
* ```
1919
*/
2020
export async function getDeviceIdForConnection(): Promise<string> {
21+
const controller = new AbortController();
22+
2123
try {
2224
const deviceId = await getDeviceId({
2325
getMachineId: () => nodeMachineId.machineId(true),
@@ -34,7 +36,7 @@ export async function getDeviceIdForConnection(): Promise<string> {
3436
break;
3537
}
3638
},
37-
abortSignal: new AbortController().signal,
39+
abortSignal: controller.signal,
3840
});
3941
return deviceId;
4042
} catch (error) {

0 commit comments

Comments
 (0)