From d80adcea8f4315c08802787c091684a940ae87a2 Mon Sep 17 00:00:00 2001 From: whitelonng Date: Thu, 20 Aug 2026 02:15:18 +0800 Subject: [PATCH] test(subprocess): treat ESRCH as gone in waitGone A pid can exit between the kill-0 probe and the /proc read; readFileSync then reports ESRCH, which is the same terminal state the ENOENT arm already accepts. The loaded coverage lane hit this race on the master push run. --- packages/subprocess/subprocess-local/tests/spawn.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/subprocess/subprocess-local/tests/spawn.spec.ts b/packages/subprocess/subprocess-local/tests/spawn.spec.ts index 1f87fd67cc..5c83273576 100644 --- a/packages/subprocess/subprocess-local/tests/spawn.spec.ts +++ b/packages/subprocess/subprocess-local/tests/spawn.spec.ts @@ -75,7 +75,9 @@ async function waitGone(pid: number, timeoutMs = 5_000): Promise { const state = stat.slice(stat.lastIndexOf(')') + 2, stat.lastIndexOf(')') + 3) if (state === 'Z' || state === 'X') return } catch (error: unknown) { - if ((error as NodeJS.ErrnoException).code === 'ENOENT') return + // ESRCH = the pid vanished between the kill-0 probe and this read, + // which is the same terminal state ENOENT reports on a settled entry. + if ((error as NodeJS.ErrnoException).code === 'ENOENT' || (error as NodeJS.ErrnoException).code === 'ESRCH') return throw error } }