Skip to content

Commit 5acb798

Browse files
committed
Add maxRetries option to fs.rm to mitigate EPERM errors on Windows
- 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.
1 parent 5b831e1 commit 5acb798

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

packages/esbuild/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ export default [
6363
async before(config) {
6464
if (config.saveBundle) {
6565
if (config.cleanDir) {
66-
await rm(config.saveBundle, { force: true, recursive: true })
66+
await rm(config.saveBundle, {
67+
force: true,
68+
maxRetries: 3,
69+
recursive: true
70+
})
6771
} else {
6872
let notEmpty = await isDirNotEmpty(config.saveBundle)
6973
if (notEmpty) {
@@ -75,7 +79,11 @@ export default [
7579

7680
async finally(config, check) {
7781
if (check.esbuildOutfile && !config.saveBundle) {
78-
await rm(check.esbuildOutfile, { force: true, recursive: true })
82+
await rm(check.esbuildOutfile, {
83+
force: true,
84+
maxRetries: 3,
85+
recursive: true
86+
})
7987
}
8088
},
8189

packages/webpack/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ export default [
5959
async before(config) {
6060
if (config.saveBundle) {
6161
if (config.cleanDir) {
62-
await rm(config.saveBundle, { force: true, recursive: true })
62+
await rm(config.saveBundle, {
63+
force: true,
64+
maxRetries: 3,
65+
recursive: true
66+
})
6367
} else {
6468
let notEmpty = await isDirNotEmpty(config.saveBundle)
6569
if (notEmpty) {
@@ -71,7 +75,11 @@ export default [
7175

7276
async finally(config, check) {
7377
if (check.webpackOutput && !config.saveBundle) {
74-
await rm(check.webpackOutput, { force: true, recursive: true })
78+
await rm(check.webpackOutput, {
79+
force: true,
80+
maxRetries: 3,
81+
recursive: true
82+
})
7583
}
7684
},
7785

0 commit comments

Comments
 (0)