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 May 26, 2024
1 parent d0d681d commit fa5ba94
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/size-limit/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export async function rm(dir) {
if (!fs.rm) {
/* c8 ignore next 3 */
if (existsSync(dir)) {
await fs.rmdir(dir, { recursive: true })
await fs.rmdir(dir, { maxRetries: 3, recursive: true })
}
} else {
await fs.rm(dir, { force: true, recursive: true })
await fs.rm(dir, { force: true, maxRetries: 3, recursive: true })
}
}

0 comments on commit fa5ba94

Please sign in to comment.