Skip to content

Commit fa5ba94

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 d0d681d commit fa5ba94

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/size-limit/rm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export async function rm(dir) {
55
if (!fs.rm) {
66
/* c8 ignore next 3 */
77
if (existsSync(dir)) {
8-
await fs.rmdir(dir, { recursive: true })
8+
await fs.rmdir(dir, { maxRetries: 3, recursive: true })
99
}
1010
} else {
11-
await fs.rm(dir, { force: true, recursive: true })
11+
await fs.rm(dir, { force: true, maxRetries: 3, recursive: true })
1212
}
1313
}

0 commit comments

Comments
 (0)