Skip to content

Commit 91f587e

Browse files
committed
fix: don't let rimraf failure prevent EPERM/EBUSY retry loop
On Windows, when the target file is locked (e.g. by antivirus or another process), both rename and rimraf fail with EPERM. Previously rimraf threw before the retry loop was reached. Now rimraf errors are swallowed so the retry loop can wait for the lock to clear.
1 parent cb233b9 commit 91f587e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rename-overwrite/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function renameOverwrite (oldPath, newPath, retry = 0) {
3030
case 'EPERM':
3131
case 'EACCESS':
3232
case 'EBUSY': {
33-
await rimraf(newPath)
33+
try { await rimraf(newPath) } catch {}
3434
const start = Date.now()
3535
let backoff = 0
3636
let lastError = err
@@ -89,7 +89,7 @@ export function renameOverwriteSync (oldPath, newPath, retry = 0) {
8989
case 'EPERM':
9090
case 'EACCESS':
9191
case 'EBUSY': {
92-
rimrafSync(newPath)
92+
try { rimrafSync(newPath) } catch {}
9393
const start = Date.now()
9494
let backoff = 0
9595
let lastError = err

0 commit comments

Comments
 (0)