From b1ce014035e234a231d9f6f76aa6d2916fc67e41 Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Sun, 2 Aug 2026 19:01:59 +0800 Subject: [PATCH] fix(code-runtime-python): restore per-file branch coverage on the reap poll The group-reap poll's deadline arm (Date.now() >= deadline) is a backstop that SIGKILL emptying the reachable group never reaches, leaving one uncovered branch under the per-file 100% gate. Mark it v8-ignore with the reason and drop the always-true graceTimer-defined guard inside pollGroup (it runs only when killing is set, so kill() has armed the timer). --- packages/code-runtime/code-runtime-python/src/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/code-runtime/code-runtime-python/src/index.ts b/packages/code-runtime/code-runtime-python/src/index.ts index 575a9076e6..f2ea5ec531 100644 --- a/packages/code-runtime/code-runtime-python/src/index.ts +++ b/packages/code-runtime/code-runtime-python/src/index.ts @@ -1082,8 +1082,15 @@ export class PythonCodeRuntime extends CodeRuntime { } const deadline = Date.now() + this.config.graceMs + CLOSE_REAP_MARGIN_MS const pollGroup = (): void => { + // The deadline is a backstop: the group is reachable by `kill(-pid)` + // and SIGKILL is uncatchable, so it always empties within graceMs — the + // `Date.now() >= deadline` arm exists only so a probe that never sees + // ESRCH (a kernel quirk) cannot hang disposal forever. + /* v8 ignore next -- SIGKILL always empties the reachable group before the deadline. */ if (groupEmpty() || Date.now() >= deadline) { - if (graceTimer !== undefined) clearTimeout(graceTimer) + // graceTimer is always defined here: pollGroup runs only when + // `killing` is set, and kill() arms graceTimer before any settle. + clearTimeout(graceTimer) finalize() return }