Skip to content

[node-core-library] Make Windows folder deletion retries consistent - #6232

Merged
Ian Clanton-Thuon (iclanton) merged 5 commits into
microsoft:mainfrom
iclanton:fix/windows-folder-deletion-retries-v2
Nov 27, 2026
Merged

Ian Clanton-Thuon (iclanton) merged 5 commits into
microsoft:mainfrom
iclanton:fix/windows-folder-deletion-retries-v2

Conversation

@iclanton

@iclanton Ian Clanton-Thuon (iclanton) commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #6230. Replaces #6231 with a spec-first implementation independently reviewed by Claude Opus 5.5 and GPT-5.3 Codex before coding.

Improve reliability for Windows callers of FileSystem.deleteFolder, deleteFolderAsync, ensureEmptyFolder, and ensureEmptyFolderAsync when another process temporarily holds a file open. Preserve the public signatures and avoid overlapping top-level async removals between retries.

The specification was reviewed before implementation and has been removed from the upstream changes at the reviewer’s request.

Details

  • Own one whole-operation budget: three Windows-only retries for errors reported as EBUSY, ENOTEMPTY, or EPERM, with waits of 100, 200, and 300 ms and no final wait. Disable Node's native retries and delays.
  • Re-enumerate names on each emptying attempt, without Dirent.parentPath or a bound this; create the folder only for ENOENT and preserve other read errors and files occupying the path.
  • Retain 10 concurrent top-level async removals. Stop starting removals after observing a failure and drain started calls before retrying or rejecting. Prefer the first non-transient error code on every platform; retries remain Windows-only.
  • Keep original error identity and existing exception decoration. Document the schedule and the boundary of the draining guarantee: it covers node-core-library's calls, not Node's internal recursive work.
  • With the user's approval, consolidate the earlier PR's still-unreleased change file into two concise, user-facing entries. This removes duplicate/contradictory native-retry wording and records the concurrency and folder read-error behavior relative to the last published package. The Node.js 20.9–20.11 and unbound-call fixes address regressions on unreleased main, not a published version.

No new public options, dependencies, engine requirements, or changes to move/moveAsync.

Historical clarification

fs-extra 7 used its own vendored rimraf, not a rimraf@2 dependency. Its three-retry policy applied to async removal on all platforms, with a separate budget at each recursion level. Sync removal instead had a Windows-only spin of up to 500 ms on a folder's final rmdir, which could silently leave the folder behind. fs-extra 10 switched to native fs.rm/rmSync without retry options.

How it was tested

  • 152 tests passed: 102 FileSystem tests and 50 Async tests, using the combined Heft selection on Linux / Node.js 24.22.1.
  • TypeScript, ESLint, and API Extractor passed with unchanged API signatures.
  • Deterministic tests use actual rejected and pending promises plus mocked sleeps, covering all four methods, exact budgets/delays, final error identity and decoration, unknown/non-transient errors, non-Windows behavior, shared enumeration/creation/deletion budgets, partial re-enumeration, mixed error priority, and draining before retry/final rejection.
  • Real filesystem tests cover missing/existing/empty folders, nested contents, relative unbound calls, and preserving an existing file.
  • rush prettier, git diff --cached --check, and rush change --verify --target-branch microsoft/main passed.

Review process

Both models approved the same spec SHA-256 (6a6e8803fa426b8f6ae6800581a35f15db31fe2a03229ef68b49a28b64ff04dc) after incorporating reviewer feedback and user decisions. Independent PR-branch reviews will follow, with iterations until both approve the same final commit.

Record the spec approved independently by Claude Opus 5.5 and GPT-5.3 Codex, including the user's changelog and error-priority decisions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Apply the independently approved spec: own the retry budget, preserve compatible folder enumeration, drain started async removals, and consolidate unreleased user-facing change notes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the upstream specification technical-only, removing session-specific review and PR-management text as requested.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@iclanton

Copy link
Copy Markdown
Member Author

Independent review consensus

Claude Opus 5.5 and GPT-5.3 Codex both explicitly APPROVE final commit 2c082a058827282ad1e7475a2765bfde8a1a0087, with no unresolved code blockers.

  • Both independently approved the specification before implementation, after incorporating feedback and the author's decisions on consolidating unreleased notes and code-only error priority.
  • Both reviewed the complete implementation branch at 93d1bc2fa3de06ff684188b3a4a520901d9b7a1a and approved it.
  • The final commit changes only the specification, retaining technical content and removing session-specific process text. Both reviewed that delta, verified that source/tests/changelog are unchanged, and approved the same final head. Revised spec SHA-256: c4f8c406f0d38b4f5ea90895f27cf6be752ffd1c8960bce73d53e4c6ac17be8b.

Validation: 152 tests passed on Node.js 24.22.1 and again on Node.js 22.23.4 (102 filesystem tests, 50 async tests). TypeScript, ESLint, API Extractor, formatting, whitespace checks, and Rush changelog coverage passed. The final commit is documentation-only and did not change those tested sources. CI remains separate from these model-review approvals.

@octogonz Pete Gonzalez (octogonz) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the PR!

Remove the specification from the upstream PR as requested in review; preserve the requested design deliverable outside the repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fixup! [node-core-library] Implement reviewed Windows deletion retries

Trim redundant folder deletion retry tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@iclanton
Ian Clanton-Thuon (iclanton) merged commit d4f2799 into microsoft:main Nov 27, 2026
8 of 9 checks passed
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Nov 27, 2026
@iclanton
Ian Clanton-Thuon (iclanton) deleted the fix/windows-folder-deletion-retries-v2 branch November 27, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

[node-core-library] Feedback for PR #5836 (FileSystem.deleteFolder retry)

2 participants