From 2b247968049a4f256f6aa79b83ba5f7868d96895 Mon Sep 17 00:00:00 2001 From: JF Date: Sat, 17 Oct 2026 00:32:13 -0400 Subject: [PATCH] test: wait for a just-spawned child to appear in the process table before asserting the helper lists it (main Windows CI red after #940) On windows-latest the first scan right after spawn() came back empty while the child was alive; a scan 300 ms later listed it. The test now polls for the listing (up to 15 s) instead of asserting the first answer. Co-Authored-By: Claude Fable 5.1 --- tests/unit/test-utils/process-table.test.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-utils/process-table.test.ts b/tests/unit/test-utils/process-table.test.ts index b4aa7205..fb2362a5 100644 --- a/tests/unit/test-utils/process-table.test.ts +++ b/tests/unit/test-utils/process-table.test.ts @@ -30,11 +30,25 @@ describe('process-table helper (issue #885)', () => { return proc; } + /** A just-spawned process takes a moment to appear in the OS process table (seconds on a cold CI runner). */ + async function waitUntilListed(pid: number, image: string, timeoutMs: number): Promise { + const deadline = Date.now() + timeoutMs; + let listed = await listPidsByImage(image); + while (!listed.includes(pid) && Date.now() < deadline) { + await new Promise((resolve) => setTimeout(resolve, 250)); + listed = await listPidsByImage(image); + } + return listed; + } + it('lists a live node child under its image and sees it alive', async () => { const proc = spawnIdleNode(); expect(isProcessAlive(proc.pid!)).toBe(true); - expect(await listPidsByImage('node')).toContain(proc.pid); - }); + // Not asserted on the first scan: on windows-latest the child was alive + // but not yet in the table when queried right after spawn (main CI on + // 42651425), while a scan 300 ms later listed it. + expect(await waitUntilListed(proc.pid!, 'node', 15_000)).toContain(proc.pid); + }, 30_000); it('answers the pid as a survivor only while it is still a process of the named image', async () => { const proc = spawnIdleNode();