From 2900eb545688d5c943afadd3835b2c8d641accc6 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 09:40:22 +0000 Subject: [PATCH] perf(test): trim background abort settle waits and dedupe cmd fixture --- ...ash-tools.exec.background-abort.e2e.test.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/agents/bash-tools.exec.background-abort.e2e.test.ts b/src/agents/bash-tools.exec.background-abort.e2e.test.ts index cc34a3e4a..6134e0ce3 100644 --- a/src/agents/bash-tools.exec.background-abort.e2e.test.ts +++ b/src/agents/bash-tools.exec.background-abort.e2e.test.ts @@ -7,6 +7,10 @@ import { import { createExecTool } from "./bash-tools.exec.js"; import { killProcessTree } from "./shell-utils.js"; +const BACKGROUND_HOLD_CMD = 'node -e "setTimeout(() => {}, 1000)"'; +const ABORT_SETTLE_MS = process.platform === "win32" ? 200 : 60; +const ABORT_WAIT_TIMEOUT_MS = process.platform === "win32" ? 1_500 : 600; + afterEach(() => { resetProcessRegistryForTests(); }); @@ -57,9 +61,9 @@ async function expectBackgroundSessionSurvivesAbort(params: { () => { const running = getSession(sessionId); const finished = getFinishedSession(sessionId); - return Date.now() - startedAt >= 100 && !finished && running?.exited === false; + return Date.now() - startedAt >= ABORT_SETTLE_MS && !finished && running?.exited === false; }, - { timeout: process.platform === "win32" ? 1_500 : 800, interval: 20 }, + { timeout: ABORT_WAIT_TIMEOUT_MS, interval: 20 }, ) .toBe(true); @@ -102,7 +106,7 @@ test("background exec is not killed when tool signal aborts", async () => { const tool = createExecTool({ allowBackground: true, backgroundMs: 0 }); await expectBackgroundSessionSurvivesAbort({ tool, - executeParams: { command: 'node -e "setTimeout(() => {}, 5000)"', background: true }, + executeParams: { command: BACKGROUND_HOLD_CMD, background: true }, }); }); @@ -110,7 +114,7 @@ test("pty background exec is not killed when tool signal aborts", async () => { const tool = createExecTool({ allowBackground: true, backgroundMs: 0 }); await expectBackgroundSessionSurvivesAbort({ tool, - executeParams: { command: 'node -e "setTimeout(() => {}, 5000)"', background: true, pty: true }, + executeParams: { command: BACKGROUND_HOLD_CMD, background: true, pty: true }, }); }); @@ -119,7 +123,7 @@ test("background exec still times out after tool signal abort", async () => { await expectBackgroundSessionTimesOut({ tool, executeParams: { - command: 'node -e "setTimeout(() => {}, 5000)"', + command: BACKGROUND_HOLD_CMD, background: true, timeout: 0.2, }, @@ -131,7 +135,7 @@ test("yielded background exec is not killed when tool signal aborts", async () = const tool = createExecTool({ allowBackground: true, backgroundMs: 10 }); await expectBackgroundSessionSurvivesAbort({ tool, - executeParams: { command: 'node -e "setTimeout(() => {}, 5000)"', yieldMs: 5 }, + executeParams: { command: BACKGROUND_HOLD_CMD, yieldMs: 5 }, }); }); @@ -140,7 +144,7 @@ test("yielded background exec still times out", async () => { await expectBackgroundSessionTimesOut({ tool, executeParams: { - command: 'node -e "setTimeout(() => {}, 5000)"', + command: BACKGROUND_HOLD_CMD, yieldMs: 5, timeout: 0.2, },