mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
test(cli): wait out Windows EBUSY when removing the ACP fixture root (#64346)
Co-authored-by: James Long <james@anoma.ly>
This commit is contained in:
committed by
GitHub
Unverified
parent
d54fe2628d
commit
d327a9662b
@@ -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<void> {
|
||||
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<InitializeResponse>("initialize", {
|
||||
|
||||
Reference in New Issue
Block a user