fix(3597): bug-1974 windows EPERM — retry rmSync on tmpDir teardown

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.
This commit is contained in:
Tom Boucher
2026-05-16 13:18:34 -04:00
parent 90e60b4145
commit 32dea2034b

View File

@@ -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`);