diff --git a/packages/core/src/__tests__/platform.mock.test.ts b/packages/core/src/__tests__/platform.mock.test.ts index 667bcc68a..a5435b19c 100644 --- a/packages/core/src/__tests__/platform.mock.test.ts +++ b/packages/core/src/__tests__/platform.mock.test.ts @@ -272,6 +272,21 @@ describe("findPidByPort", () => { expect(pid).toBeNull(); }); + it("finds PID from IPv6 LISTENING line on Windows", async () => { + setPlatform("win32"); + // netstat -ano includes IPv6 entries like [::]:3000 when server binds to all interfaces + const netstatOutput = [ + " Proto Local Address Foreign Address State PID", + " TCP [::]:3000 [::]:0 LISTENING 55", + ].join("\n"); + resolveExecFile(netstatOutput); + + const mod = await import("../platform.js"); + const pid = await mod.findPidByPort(3000); + + expect(pid).toBe("55"); + }); + it("returns null when no LISTENING line matches on Windows", async () => { setPlatform("win32"); resolveExecFile(" TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 99\n"); diff --git a/packages/core/src/platform.ts b/packages/core/src/platform.ts index 6f3f65b19..987025ba6 100644 --- a/packages/core/src/platform.ts +++ b/packages/core/src/platform.ts @@ -63,7 +63,9 @@ export function getShell(): ShellInfo { return cachedShell; } -/** Reset cached shell (for testing) */ +/** Reset cached shell (for testing) + * @internal + */ export function _resetShellCache(): void { cachedShell = null; }