fix(build): retry dist cleanup to avoid intermittent ENOTEMPTY in CI

This commit is contained in:
Santosh Madugundi 2026-04-16 14:37:45 -07:00
parent b60829d16d
commit a2576ad24d

View file

@ -10,6 +10,24 @@ import { copyPaths, copyWasms, copyLocales, setupLocaleWatcher } from "@roo-code
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
async function removeDirWithRetries(dirPath, retries = 5, retryDelayMs = 200) {
for (let attempt = 0; attempt <= retries; attempt++) {
try {
await fs.promises.rm(dirPath, { recursive: true, force: true })
return
} catch (error) {
const isRetryable = error?.code === "ENOTEMPTY" || error?.code === "EBUSY" || error?.code === "EPERM"
const isLastAttempt = attempt === retries
if (!isRetryable || isLastAttempt) {
throw error
}
await new Promise((resolve) => globalThis.setTimeout(resolve, retryDelayMs * (attempt + 1)))
}
}
}
async function main() {
const name = "extension"
const production = process.argv.includes("--production")
@ -36,7 +54,7 @@ async function main() {
if (fs.existsSync(distDir)) {
console.log(`[${name}] Cleaning dist directory: ${distDir}`)
fs.rmSync(distDir, { recursive: true, force: true })
await removeDirWithRetries(distDir)
}
/**