Skip to content

Retry esbuild tree removals with backoff for transient EPERM - #282

Open
francescovidaich964 wants to merge 1 commit into
advaitpaliwal:mainfrom
francescovidaich964:fix/esbuild-rm-perm-retry
Open

Retry esbuild tree removals with backoff for transient EPERM#282
francescovidaich964 wants to merge 1 commit into
advaitpaliwal:mainfrom
francescovidaich964:fix/esbuild-rm-perm-retry

Conversation

@francescovidaich964

@francescovidaich964 francescovidaich964 commented Sep 10, 2026

Copy link
Copy Markdown

Summary

Fixes #281. On Windows, rmSync at scripts/lib/pi-esbuild-package-patch.mjs:485 races Defender's handle on a freshly written 11.6 MB esbuild.exe, throwing intermittent EPERM during npm test / prepack. The repo already solved this in scripts/lib/temporary-tree-cleanup.mjs (removeTemporaryTree, which retries EPERM and other removal codes with exponential backoff); this call site just never used it.

Changes

  • scripts/lib/pi-esbuild-package-patch.mjs — replace the bare rmSync(dir, { recursive: true }) with removeTemporaryTree(dir) (adds force: true plus bounded retries with exponential backoff).

Test note

No new call-site test: the helper is already tested in tests/temporary-tree-cleanup.test.ts (injects a failing remove to simulate EPERM). Asserting retry behavior at this call site would require widening patchPiEsbuildPackageTree's API purely for testability — happy to add that plumbing if preferred.

Verification

  • npm run typecheck — pass
  • Touched test file (tests/pi-esbuild-package-patch.test.ts) passes in full for the covered behavior; the full file on Windows has 5 failures, all pre-existing non-elevated symlink EPERM at fixture setup (identical on clean main)
  • The full suite on Windows has 109 pre-existing failures at clean main; this change adds none

CI status

  • The ubuntu npm test workflow has not run on this PR yet: fork workflow runs await maintainer approval.
  • The Vercel check fails only because fork PRs need deploy authorization from a team member; it is not a build or test failure.
  • GitGuardian security checks pass.

Notes

This PR was prepared with AI assistance; the contributor verified the diff against the current source before opening.

replacePortableTree removals race antivirus handles on a freshly written
esbuild binary on Windows. Use removeTemporaryTree, which retries
EPERM and other removal codes with exponential backoff, instead of a
bare rmSync without force.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

@francescovidaich964 is attempting to deploy a commit to the Advait Paliwal's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rmSync races antivirus handle on freshly written esbuild.exe — intermittent EPERM in npm test/prepack on Windows

1 participant