test(subagent-codex): use async rm for real-product temp cleanup

Switch the afterEach cleanup from rmSync to the async rm with 10
retries, matching subagent-claude-code. On native Windows the
synchronous rmSync retry window (5 x 100ms) is too short for the
real Codex subprocess to release its directory handles after exit,
so cleanup repeatedly fails with EPERM; the async variant with a
wider retry window drains the handles before removing the tree.
This commit is contained in:
Chinesezjc
2026-08-11 12:28:50 +08:00
parent 8424a73cd8
commit f7745a35e1
@@ -4,9 +4,9 @@ import {
mkdirSync,
mkdtempSync,
readFileSync,
rmSync,
writeFileSync,
} from 'node:fs'
import { rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { delimiter, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
@@ -41,7 +41,7 @@ afterEach(async () => {
await Promise.all(contexts.splice(0).map(ctx => ctx.fiber.dispose()))
await Promise.all(fixtures.splice(0).map(fixture => fixture.close()))
for (const root of roots.splice(0)) {
rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })
await rm(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })
}
})