Skip to content

[rush] Use AsyncRecycler for autoinstaller cleanup#5756

Open
kevin-y-ang wants to merge 4 commits intomicrosoft:mainfrom
kevin-y-ang:feat/autoinstaller-move-to-trash
Open

[rush] Use AsyncRecycler for autoinstaller cleanup#5756
kevin-y-ang wants to merge 4 commits intomicrosoft:mainfrom
kevin-y-ang:feat/autoinstaller-move-to-trash

Conversation

@kevin-y-ang
Copy link
Copy Markdown
Contributor

@kevin-y-ang kevin-y-ang commented Apr 8, 2026

Summary

Deleting old files from **/node_modules is 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_modules folders 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 autoinstaller node_modules folder. This change switches that path to AsyncRecycler, which first renames the folder into common/temp/rush-recycler and 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_modules tree, runs prepareAsync(), 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 --clean
  • pnpm --dir libraries/rush-lib exec heft test --clean --test-path-pattern Autoinstaller.test

@github-project-automation github-project-automation bot moved this to Needs triage in Bug Triage Apr 8, 2026
@kevin-y-ang kevin-y-ang force-pushed the feat/autoinstaller-move-to-trash branch from a0cf941 to 162a383 Compare April 8, 2026 04:46
@kevin-y-ang kevin-y-ang marked this pull request as ready for review April 8, 2026 23:07
kevin-y-ang and others added 2 commits April 9, 2026 15:07
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants