Skip to content

Commit 795c4f4

Browse files
committed
fix: capture OS.networkInterfaces() once in getDesktopAdvertisedEndpoints
Avoid calling OS.networkInterfaces() twice with an await in between, which could yield inconsistent snapshots if network state changes. A single local variable is now shared by both resolveDesktopServerExposure and resolveTailscaleAdvertisedEndpoints.
1 parent b585c3d commit 795c4f4

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

apps/desktop/src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,11 @@ function getDesktopServerExposureState(): DesktopServerExposureState {
315315
}
316316

317317
async function getDesktopAdvertisedEndpoints() {
318+
const networkInterfaces = OS.networkInterfaces();
318319
const exposure = resolveDesktopServerExposure({
319320
mode: desktopServerExposureMode,
320321
port: backendPort,
321-
networkInterfaces: OS.networkInterfaces(),
322+
networkInterfaces,
322323
...(backendAdvertisedHost ? { advertisedHostOverride: backendAdvertisedHost } : {}),
323324
});
324325
const coreEndpoints = resolveDesktopCoreAdvertisedEndpoints({
@@ -328,7 +329,7 @@ async function getDesktopAdvertisedEndpoints() {
328329
});
329330
const tailscaleEndpoints = await resolveTailscaleAdvertisedEndpoints({
330331
port: backendPort,
331-
networkInterfaces: OS.networkInterfaces(),
332+
networkInterfaces,
332333
});
333334
return [...coreEndpoints, ...tailscaleEndpoints];
334335
}

0 commit comments

Comments
 (0)