diff --git a/tests/archive.spec.ts b/tests/archive.spec.ts index 7b470512..e0d47664 100644 --- a/tests/archive.spec.ts +++ b/tests/archive.spec.ts @@ -268,12 +268,16 @@ beforeEach(() => { }) afterEach(async () => { + // `start()` launches `pack()` detached; give its open/spawn a beat to land + // before dispose kills the child. Disposing first lets a late open create a + // temp file AFTER the cleanup below has already walked the tree. + await new Promise(resolve => setTimeout(resolve, 50)) // Before the mocks go: `dispose()` kills through a fake whose `kill` is a // `vi.fn`, and those implementations do not survive a restore. for (const tasks of tables.splice(0)) tasks.dispose() // A killed child closes asynchronously; let the close land (and the packer // close its descriptor) before the directories underneath it disappear. - await new Promise(resolve => setTimeout(resolve, 0)) + await new Promise(resolve => setTimeout(resolve, 50)) for (const [key, value] of Object.entries(savedTmp)) { if (value === undefined) delete process.env[key] else process.env[key] = value diff --git a/tests/temp-tree.ts b/tests/temp-tree.ts index 1ae94736..35515f0b 100644 --- a/tests/temp-tree.ts +++ b/tests/temp-tree.ts @@ -14,7 +14,8 @@ * `maxRetries` + `retryDelay` is Node's own remedy for exactly this, so every * risky cleanup goes through here instead of repeating the retry inline. * The same archive cleanup flaked again on 2026-10-28 under a loaded runner, - * so the budget now covers a slower handle release than the original 10×50 ms. + * so the budget now covers a slower handle release than the original 10×50 ms; + * the Windows lane still hit it once on 2026-10-29, hence the 6 s budget. * POSIX runs are unaffected: the first attempt succeeds and no retry happens. */ import { rmSync } from 'node:fs' @@ -25,5 +26,5 @@ import { rmSync } from 'node:fs' * @param path - file or directory to remove (missing paths are ignored). */ export function removeTree(path: string): void { - rmSync(path, { recursive: true, force: true, maxRetries: 30, retryDelay: 100 }) + rmSync(path, { recursive: true, force: true, maxRetries: 60, retryDelay: 100 }) }