test: let detached archive packs land before cleanup
This commit is contained in:
1 parent
173e01030a
commit
10ccebb052
2 files changed
+8
-3
No files matched your search
@@ -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
|
||||
|
||||
+3
-2
@@ -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 })
|
||||
}
|
||||
Reference in new issue
Block a user