fix(dlx): make failed-install cache cleanup best-effort on Windows (#… · pnpm/pnpm@d577eea · GitHub
Skip to content

Commit d577eea

Browse files
authored
fix(dlx): make failed-install cache cleanup best-effort on Windows (#12575)
* fix(dlx): make failed-install cache cleanup best-effort On Windows, `pnpm dlx` could fail with a spurious "EBUSY: resource busy or locked, rmdir" error. When an install into the dlx cache failed, the catch block removed the partially-populated prepare dir with `fs.promises.rm(cachedDir, { recursive: true, force: true })`. That call has no retries, so it died on the same lingering Windows handle (a just-run install script's child process, or antivirus scanning freshly written files) and threw EBUSY — which then replaced and masked the original install error. Make the cleanup best-effort: swallow its failure so the original error always surfaces, and add `maxRetries`/`retryDelay` so the removal itself succeeds once the transient lock clears. A leftover prepare dir is harmless — it has a unique name and findCache only trusts the `pkg` symlink. The pacquet port already removes the prepare dir best-effort (`let _ = fs::remove_dir_all(...)`) and returns the original error, so the user-visible behavior already matches; only the (non-observable) retry is absent there. * fix(dlx): log dlx cache cleanup failures instead of swallowing them Catch the best-effort cache cleanup with a narrow handler that logs the failure via logger.warn (mirroring tryRemovePkg in modules-cleaner's prune) instead of a blanket `.catch(() => {})`. The original install error is still the one rethrown, so cleanup failures stay visible without ever masking the real cause.
1 parent 0ec878d commit d577eea

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions

pnpm11/exec/commands/src/dlx.ts

Lines changed: 17 additions & 2 deletions

0 commit comments

Comments
 (0)