[rush] Use AsyncRecycler for autoinstaller cleanup#5756
Open
kevin-y-ang wants to merge 4 commits intomicrosoft:mainfrom
Open
[rush] Use AsyncRecycler for autoinstaller cleanup#5756kevin-y-ang wants to merge 4 commits intomicrosoft:mainfrom
kevin-y-ang wants to merge 4 commits intomicrosoft:mainfrom
Conversation
a0cf941 to
162a383
Compare
iclanton
reviewed
Apr 9, 2026
iclanton
reviewed
Apr 9, 2026
iclanton
reviewed
Apr 9, 2026
...on/changes/@microsoft/rush/autoinstaller-move-node-modules-to-recycler_2026-04-07-18-05.json
Outdated
Show resolved
Hide resolved
- Use string interpolation instead of path.join - Avoid race condition from checking if file exists before operating on it Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deleting old files from **/node_modulesis a process invoked for every autoinstaller install.For large rush repos, this takes a lot of time. On my computer this process can take half a minute.
This fixes autoinstaller cleanup so stale
node_modulesfolders are moved into Rush's recycler before deletion instead of being cleared in place.Details
When an autoinstaller install is invalidated, Rush previously called
FileSystem.ensureEmptyFolder()on the autoinstallernode_modulesfolder. This change switches that path toAsyncRecycler, which first renames the folder intocommon/temp/rush-recyclerand then starts asynchronous deletion. That keeps the cleanup path cross-platform and consistent with other Rush cleanup flows.I also added a targeted unit test that seeds an autoinstaller
node_modulestree, runsprepareAsync(), and verifies the old tree was moved into the recycler before reinstall.This does not change public APIs.
How it was tested
pnpm --dir libraries/rush-lib exec heft build --cleanpnpm --dir libraries/rush-lib exec heft test --clean --test-path-pattern Autoinstaller.test