From d327a9662b1218296cd26e8a52a661cf17f5a8c6 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 21:42:06 -0500 Subject: [PATCH] test(cli): wait out Windows EBUSY when removing the ACP fixture root (#64346) Co-authored-by: James Long --- packages/cli/test/acp/subprocess.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/cli/test/acp/subprocess.ts b/packages/cli/test/acp/subprocess.ts index 9ca913371f8..c0265fb5dd3 100644 --- a/packages/cli/test/acp/subprocess.ts +++ b/packages/cli/test/acp/subprocess.ts @@ -97,9 +97,7 @@ export async function createAcpFixture( [...processes].map((process) => process.close().catch(() => process[Symbol.asyncDispose]())), ) const serverResults = await Promise.allSettled([llm.stop(true)]) - const directoryResults = await Promise.allSettled([ - fs.rm(root, { recursive: true, force: true, maxRetries: 20, retryDelay: 100 }), - ]) + const directoryResults = await Promise.allSettled([removeRoot(root)]) const failure = [...processResults, ...serverResults, ...directoryResults].find( (result): result is PromiseRejectedResult => result.status === "rejected", ) @@ -108,6 +106,19 @@ export async function createAcpFixture( } } +// ACP exits without waiting for its standalone server, which holds files under root until its own teardown ends. +// On Windows removal fails with EBUSY until then, which can outlast fs.rm's own retries, so retry for longer. +async function removeRoot(root: string, deadline = Date.now() + 15_000): Promise { + try { + await fs.rm(root, { recursive: true, force: true }) + } catch (error) { + const busy = !!error && typeof error === "object" && "code" in error && error.code === "EBUSY" + if (!busy || Date.now() >= deadline) throw error + await Bun.sleep(100) + return removeRoot(root, deadline) + } +} + export function initialize(acp: AcpProcess) { return acp .request("initialize", {