From 9ab7b85a66de5d800e2110e4e419a768d7eb7cfd Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 10:21:46 +0000 Subject: [PATCH] perf(test): tighten background abort timing windows --- ...bash-tools.exec.background-abort.e2e.test.ts | 17 ++++++++++------- 1 file changed, 10 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 6134e0ce3..6a5af48ad 100644 --- a/src/agents/bash-tools.exec.background-abort.e2e.test.ts +++ b/src/agents/bash-tools.exec.background-abort.e2e.test.ts @@ -7,9 +7,12 @@ import { import { createExecTool } from "./bash-tools.exec.js"; import { killProcessTree } from "./shell-utils.js"; -const BACKGROUND_HOLD_CMD = 'node -e "setTimeout(() => {}, 1000)"'; +const BACKGROUND_HOLD_CMD = 'node -e "setTimeout(() => {}, 500)"'; const ABORT_SETTLE_MS = process.platform === "win32" ? 200 : 60; -const ABORT_WAIT_TIMEOUT_MS = process.platform === "win32" ? 1_500 : 600; +const ABORT_WAIT_TIMEOUT_MS = process.platform === "win32" ? 1_500 : 450; +const POLL_INTERVAL_MS = 15; +const FINISHED_WAIT_TIMEOUT_MS = process.platform === "win32" ? 8_000 : 1_200; +const BACKGROUND_TIMEOUT_SEC = process.platform === "win32" ? 0.2 : 0.12; afterEach(() => { resetProcessRegistryForTests(); @@ -24,8 +27,8 @@ async function waitForFinishedSession(sessionId: string) { return Boolean(finished); }, { - timeout: process.platform === "win32" ? 10_000 : 2_000, - interval: 20, + timeout: FINISHED_WAIT_TIMEOUT_MS, + interval: POLL_INTERVAL_MS, }, ) .toBe(true); @@ -63,7 +66,7 @@ async function expectBackgroundSessionSurvivesAbort(params: { const finished = getFinishedSession(sessionId); return Date.now() - startedAt >= ABORT_SETTLE_MS && !finished && running?.exited === false; }, - { timeout: ABORT_WAIT_TIMEOUT_MS, interval: 20 }, + { timeout: ABORT_WAIT_TIMEOUT_MS, interval: POLL_INTERVAL_MS }, ) .toBe(true); @@ -125,7 +128,7 @@ test("background exec still times out after tool signal abort", async () => { executeParams: { command: BACKGROUND_HOLD_CMD, background: true, - timeout: 0.2, + timeout: BACKGROUND_TIMEOUT_SEC, }, abortAfterStart: true, }); @@ -146,7 +149,7 @@ test("yielded background exec still times out", async () => { executeParams: { command: BACKGROUND_HOLD_CMD, yieldMs: 5, - timeout: 0.2, + timeout: BACKGROUND_TIMEOUT_SEC, }, }); });