diff --git a/packages/runtime-core/src/provider/publication.rs b/packages/runtime-core/src/provider/publication.rs index fe5a034b0..e69eccd14 100644 --- a/packages/runtime-core/src/provider/publication.rs +++ b/packages/runtime-core/src/provider/publication.rs @@ -854,7 +854,16 @@ mod port_probe_tests { "published_port_in_use" ); drop(exact); - require_loopback_port_free(port).unwrap(); + // Parallel tests can take a just-released ephemeral port, and a loaded + // runner can time out the probe's connect. Either reads as in use, so + // accept the first of several freshly released ports the probe clears. + let freed = (0..20).any(|_| { + let probe = TcpListener::bind((Ipv4Addr::LOCALHOST, 0)).unwrap(); + let port = probe.local_addr().unwrap().port(); + drop(probe); + require_loopback_port_free(port).is_ok() + }); + assert!(freed, "the probe never accepted a released loopback port"); // A wildcard listener would share loopback traffic under SO_REUSEADDR. let wildcard = TcpListener::bind((Ipv4Addr::UNSPECIFIED, 0)).unwrap(); let port = wildcard.local_addr().unwrap().port(); diff --git a/tests/doctor-fix-noninteractive.test.ts b/tests/doctor-fix-noninteractive.test.ts index 3f5c443f2..764081500 100644 --- a/tests/doctor-fix-noninteractive.test.ts +++ b/tests/doctor-fix-noninteractive.test.ts @@ -248,7 +248,7 @@ test("doctor --fix under HACK_NO_INTERACTIVE clears a stale daemon pid without p expect(runCalls).toEqual( expect.arrayContaining([expect.arrayContaining(["daemon", "clear"])]) ); -}); +}, 30_000); test("doctor --fix under HACK_NO_INTERACTIVE skips macOS keychain repair and reports it", async () => { const projectRoot = await createProjectWithStaleDaemonPid(); @@ -273,7 +273,7 @@ test("doctor --fix under HACK_NO_INTERACTIVE skips macOS keychain repair and rep if (skippedNote !== undefined) { expect(skippedNote).not.toContain("Repair macOS host TLS trust"); } -}); +}, 30_000); test("doctor --fix never calls the raw clack confirm prompt under HACK_NO_INTERACTIVE", async () => { const projectRoot = await createProjectWithStaleDaemonPid(); @@ -291,7 +291,7 @@ test("doctor --fix never calls the raw clack confirm prompt under HACK_NO_INTERA // proves every prompt site in the --fix path routed through confirmSafe's // non-interactive branch instead of the raw clack prompt. expect(code).toBe(0); -}); +}, 30_000); test("doctor --fix creates a missing .hack/.gitignore and keeps user lines on a repair (HACK-1278)", async () => { const projectRoot = await createProjectWithStaleDaemonPid();