fix(test): close reopened persistence before removing its root

This commit is contained in:
liukx0205 committed 2026-11-15 01:41:29 +08:00
1 parent 0317e25314
commit 76ca40e741
1 file changed
+3 -4
@@ -68,13 +68,12 @@ class GatedAdapter extends LlmAdapter {
}
}
// Each persistence-backed temp root cleans up by closing its handle before
// removing the directory: Windows rmSync over a dir holding a still-open handle
// fails with EPERM.
// Close later contexts that reopen a root before its owning cleanup removes it;
// Windows rejects removal while any SQLite connection still holds the files.
const cleanups: Array<() => Promise<void>> = []
afterEach(async () => {
const errors: unknown[] = []
for (const cleanup of cleanups.splice(0)) {
for (const cleanup of cleanups.splice(0).reverse()) {
try { await cleanup() } catch (error) { errors.push(error) }
}
if (errors.length === 1) throw errors[0]