Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit a2576ad

Browse files
committed
fix(build): retry dist cleanup to avoid intermittent ENOTEMPTY in CI
1 parent b60829d commit a2576ad

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/esbuild.mjs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ import { copyPaths, copyWasms, copyLocales, setupLocaleWatcher } from "@roo-code
1010
const __filename = fileURLToPath(import.meta.url)
1111
const __dirname = path.dirname(__filename)
1212

13+
async function removeDirWithRetries(dirPath, retries = 5, retryDelayMs = 200) {
14+
for (let attempt = 0; attempt <= retries; attempt++) {
15+
try {
16+
await fs.promises.rm(dirPath, { recursive: true, force: true })
17+
return
18+
} catch (error) {
19+
const isRetryable = error?.code === "ENOTEMPTY" || error?.code === "EBUSY" || error?.code === "EPERM"
20+
const isLastAttempt = attempt === retries
21+
22+
if (!isRetryable || isLastAttempt) {
23+
throw error
24+
}
25+
26+
await new Promise((resolve) => globalThis.setTimeout(resolve, retryDelayMs * (attempt + 1)))
27+
}
28+
}
29+
}
30+
1331
async function main() {
1432
const name = "extension"
1533
const production = process.argv.includes("--production")
@@ -36,7 +54,7 @@ async function main() {
3654

3755
if (fs.existsSync(distDir)) {
3856
console.log(`[${name}] Cleaning dist directory: ${distDir}`)
39-
fs.rmSync(distDir, { recursive: true, force: true })
57+
await removeDirWithRetries(distDir)
4058
}
4159

4260
/**

0 commit comments

Comments
 (0)