From f3afea921e3cad514264b55447b345c76732fb8d Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 31 Aug 2026 00:35:16 +0900 Subject: [PATCH] test(pty): mark cancellation before cleanup signal --- .../test/fixtures/native-wait-threadpool-starvation.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/pty/test/fixtures/native-wait-threadpool-starvation.mjs b/packages/pty/test/fixtures/native-wait-threadpool-starvation.mjs index ba9e58cadd..2619d509f0 100644 --- a/packages/pty/test/fixtures/native-wait-threadpool-starvation.mjs +++ b/packages/pty/test/fixtures/native-wait-threadpool-starvation.mjs @@ -79,14 +79,16 @@ try { } finally { for (const session of sessions) { try { - session.kill("SIGKILL"); + // Mark cancellation before signalling so a fast exit cannot beat the + // waiter's cancellation flag observation. + session.kill(); } catch { // The child may have exited while another session was being stopped. } try { - session.kill(); + session.kill("SIGKILL"); } catch { - // Mark cancellation even if the explicit SIGKILL already won the race. + // The cancellation-marking kill already stopped the process. } } const exits = await deadline(Promise.all(waits), 5_000, "PTY_CLEANUP_TIMEOUT");