From 32dea2034b4fae1bd001a5904e4beef4f2fc8168 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Sat, 16 May 2026 13:18:34 -0400 Subject: [PATCH] =?UTF-8?q?fix(3597):=20bug-1974=20windows=20EPERM=20?= =?UTF-8?q?=E2=80=94=20retry=20rmSync=20on=20tmpDir=20teardown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test spawns a fire-and-forget subprocess; on Windows the child may still hold a handle on tmpDir when afterEach runs, producing EPERM from fs.rmSync. Match helpers.cleanup() retry budget (20 × 250ms = 5s) to absorb the deferred-handle window without pulling in the helper (this suite predates it). Closes the Windows test (windows-latest, 24/26) lane failure on #3649. --- tests/bug-1974-context-exhaustion-record.test.cjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/bug-1974-context-exhaustion-record.test.cjs b/tests/bug-1974-context-exhaustion-record.test.cjs index 2cebdd82b..737a30d17 100644 --- a/tests/bug-1974-context-exhaustion-record.test.cjs +++ b/tests/bug-1974-context-exhaustion-record.test.cjs @@ -99,7 +99,10 @@ describe('#1974 context exhaustion auto-record', () => { }); afterEach(() => { - fs.rmSync(tmpDir, { recursive: true, force: true }); + // Windows: AV/file-indexer/not-yet-exited fire-and-forget subprocess may + // still hold a handle on tmpDir at teardown. Match the helpers.cleanup() + // retry budget (20 × 250ms = 5s) to absorb the deferred-handle window. + fs.rmSync(tmpDir, { recursive: true, force: true, maxRetries: 20, retryDelay: 250 }); // Clean up bridge files try { const warnPath = path.join(os.tmpdir(), `claude-ctx-${sessionId}-warned.json`);