Skip to content

Commit

Permalink
Add maxRetries option to fs.rm to mitigate EPERM errors on Windows
Browse files Browse the repository at this point in the history
- When using the `--save-bundle` and `--clean-dir` CLI arguments, we can get intermittent `EPERM` errors on Windows. Passing in the `maxRetries` option to `fs.rm` and `fs.rmdir` functions seems to resolve this issue.
  • Loading branch information
aryaemami59 committed Oct 26, 2024
1 parent 22c14ee commit 7653bc8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions packages/esbuild/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export default [
async before(config) {
if (config.saveBundle) {
if (config.cleanDir) {
await rm(config.saveBundle, { force: true, recursive: true })
await rm(config.saveBundle, {
force: true,
maxRetries: 3,
recursive: true
})
} else {
let notEmpty = await isDirNotEmpty(config.saveBundle)
if (notEmpty) {
Expand All @@ -75,7 +79,11 @@ export default [

async finally(config, check) {
if (check.esbuildOutfile && !config.saveBundle) {
await rm(check.esbuildOutfile, { force: true, recursive: true })
await rm(check.esbuildOutfile, {
force: true,
maxRetries: 3,
recursive: true
})
}
},

Expand Down
12 changes: 10 additions & 2 deletions packages/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export default [
async before(config) {
if (config.saveBundle) {
if (config.cleanDir) {
await rm(config.saveBundle, { force: true, recursive: true })
await rm(config.saveBundle, {
force: true,
maxRetries: 3,
recursive: true
})
} else {
let notEmpty = await isDirNotEmpty(config.saveBundle)
if (notEmpty) {
Expand All @@ -71,7 +75,11 @@ export default [

async finally(config, check) {
if (check.webpackOutput && !config.saveBundle) {
await rm(check.webpackOutput, { force: true, recursive: true })
await rm(check.webpackOutput, {
force: true,
maxRetries: 3,
recursive: true
})
}
},

Expand Down

0 comments on commit 7653bc8

Please sign in to comment.