From a1d8718fdc5bf20819cc2d1a75199cdb38c30cee Mon Sep 17 00:00:00 2001 From: Jude Gao Date: Sun, 31 May 2026 22:22:31 -0400 Subject: [PATCH] test: give afterAll teardown an explicit timeout to fix Windows CI flake The afterAll hook in nextjs-runtime-discovery.test.ts kills the spawned Next.js dev server and then rm -rf's a temp dir containing a full node_modules. On Windows CI runners that cleanup can take ~14s, exceeding vitest's global hookTimeout (10000ms), producing a flaky 'Hook timed out in 10000ms' failure even though all 38 tests pass. beforeAll already passes SERVER_STARTUP_TIMEOUT; give afterAll an explicit CLEANUP_TIMEOUT (60s) so teardown isn't capped by the global hook timeout. --- test/unit/nextjs-runtime-discovery.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/unit/nextjs-runtime-discovery.test.ts b/test/unit/nextjs-runtime-discovery.test.ts index 35772b2..e87af2d 100644 --- a/test/unit/nextjs-runtime-discovery.test.ts +++ b/test/unit/nextjs-runtime-discovery.test.ts @@ -41,6 +41,9 @@ function forceKillProcessTree(proc: ChildProcess): void { const FIXTURE_SOURCE = join(__dirname, "../fixtures/nextjs16-minimal") const TEST_PORT = 3456 const SERVER_STARTUP_TIMEOUT = 180000 +// Teardown kills the dev server and rm -rf's a temp dir containing a full +// node_modules; on Windows CI this can exceed vitest's default 10s hookTimeout. +const CLEANUP_TIMEOUT = 60000 const TEST_TIMEOUT = 240000 describe("nextjs-runtime-discovery", () => { @@ -194,7 +197,7 @@ describe("nextjs-runtime-discovery", () => { console.error("[Test] Failed to clean up temp directory:", error) } } - }) + }, CLEANUP_TIMEOUT) it( "should discover Next.js server on non-standard port via process discovery",