Repository navigation
fix(windows): stop recursive deletes from retry-storming when a file is held open - #33722
Conversation
…is held open Node's async recursive rm retries every nested entry separately and orphans sibling walkers when it rejects, so deleting a workspace holding a live browser profile multiplied filesystem work per directory level until the main process hung. Delete Windows host trees with a walker that retries whole passes from one shared budget and leaves nothing running on failure. Also bound and log detached worktree removal, and fail a file transaction whose proper-lockfile lock is compromised instead of throwing from its timer.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
38381112-68f5-4065-a18e-a4e4b5fb4efa
Files selected for processing: 21-
src/main/asar-transparent-fs.tssrc/main/browser/browser-client-upload-staging.tssrc/main/codex/codex-hook-trust-derivation.tssrc/main/file-transaction-lock.test.tssrc/main/file-transaction-lock.tssrc/main/git/worktree-removal.tssrc/main/host-tree-removal.tssrc/main/ipc/worktrees/removal/remove-registered-local-worktree.tssrc/main/local-worktree-filesystem.test.tssrc/main/local-worktree-filesystem.tssrc/main/local-worktree-removal-recovery.tssrc/main/managed-server/host-state/orcad-windows-host-state-ops.tssrc/main/observability/instrumentation.tssrc/main/runtime/runtime-registered-local-worktree-removal.tssrc/main/window/owned-temp-staging-root.tssrc/main/worktree-background-removal.test.tssrc/main/worktree-background-removal.tssrc/main/worktree-removal-deadline.tssrc/shared/bounded-tree-removal.test.tssrc/shared/bounded-tree-removal.tssrc/shared/windows-transient-lock-removal.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
-
…om walker Replace the hand-rolled tree walker with Node's own recursive rm and no per-entry retries. Async rm gives each nested entry its own retry counter and never stops siblings, which is what multiplied the work; with retries off each pass is one bounded walk, and a transient Windows lock repeats the whole pass from the existing 250/500/1000/2000 ms budget, checking the job's signal between passes. A failed delete now names the file another program holds open instead of Node's EBUSY/EPERM text. Drop the 30-minute background deadline. The lost-lock error no longer embeds the library's message and says the write may or may not have been saved.
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8200e74e-5d90-4dab-816a-25279da59b68
Files selected for processing: 5-
src/main/file-transaction-lock.tssrc/main/host-tree-removal.tssrc/main/local-worktree-filesystem.test.tssrc/shared/windows-path-access.tssrc/shared/windows-transient-lock-removal.ts
Files skipped from review as they are similar to previous changes: 1-
- src/main/file-transaction-lock.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
-
|
Windows workspace deletion could multiply Node’s retries at every directory level when another program held a file open. Orca could keep doing filesystem work after reporting failure, exhaust memory and stop responding. This PR uses plain Node recursive deletion and at most five whole-folder attempts per shared Windows helper call. Failure names the held file. When Git already unregistered the incomplete checkout, the stored failed-row tooltip says manual folder cleanup may be needed after closing the program; generic request-error toast wording is unchanged. A lost file-transaction lock now rejects the transaction instead of throwing from its refresh timer. The whole-pass policy and original-fs handling are intentional differences from the common plain-delete pattern. No deadline or cancellation of an in-flight filesystem call is promised. Node may finish already-started sibling removals after the helper reports failure. If the transaction itself fails, its error remains primary even if lock ownership was also lost. Temporary limitation: the observed close-and-retry attempt FAILED and remains open. Metadata-last ordering and successful safe retry belong to the follow-up PR in this lane (tracked in the lane, not yet opened), owned by the lane owner with separate planning, review, tests, Windows QA and performance acceptance. Brennan approved this staged delivery on 2026-10-26. This cut retains the existing replacement-folder safety guard and does not grant recursion from a saved path. No recovery finding is marked passed by removing its unshipped mechanism from this PR. Five review rounds completed; final copy correction and test-comment verification were bounded continuations of round five. No open P0/P1 remains in this shipped cut. The final whole-PR source/reference/readiness audit and the real Windows operation contract were completed. Fresh CI passed on Native Windows focused tests at The unchanged run-row deletion mechanics carry from The old six-file Windows invocation remains 79 passed / 4 failed / 1 skipped, exit 1; current clipboard repairs pass above, while unchanged mocked WSL-prune/symlink-policy fixture failures are qualified, not called passing. Latest launch cleanup: 16 recorded identities, zero owned survivors/listeners; 40 readable real-config hashes unchanged, 19 absent, 10 inaccessible inputs unverified. Earlier audit checked 24 recorded process identities, with no owned survivors or used-port listeners. Ticket 2547 released; no test copy remains running. For Brennan’s review:
|




Deleting a Windows workspace containing a live Edge or Chrome profile could multiply Node’s recursive-delete retries at every directory level. Orca could continue filesystem work after reporting failure, grow to gigabytes of memory and stop responding. This PR removes those per-entry retries and prevents a lost file-transaction lock from throwing out of its refresh timer.
What changes
rmwithrecursive: true, force: true, withoutmaxRetries. Windows makes at most five whole-pass attempts, with 250/500/1000/2000 ms waits between attempts. Other platforms make one plain pass. This bounds attempts per helper invocation, not filesystem-call duration or all work in a user action. Node may finish already-started sibling removals after the helper reports failure. The embedded Windows host-state script retains its existing separate six-attempt/1500 ms budget.removeHostTreepreserves original-fs handling for.asarfiles and Windows long paths. It names the held file in plain words. Cancellation works between passes and during backoff; a running filesystem pass is not interrupted.The plain Node deletion follows the common pattern. The short whole-pass Windows retry is intentional for handles released late after Orca stops its terminals. Sync removal, existing deletion ownership checks, explicit WSL/SSH routing and saved/wire formats are unchanged.
Temporary recovery limitation
Closing the browser and choosing Delete again can still leave the folder and failed row. Windows QA reproduced this: Git registration and
.gitwere gone, and the existing replacement-folder safety guard refused further recursive deletion. This PR’s new stored tooltip acknowledges that limitation; it does not fix or claim successful recovery. Metadata-last ordering and safe successful retry belong to the follow-up PR #34058. Brennan approved this staged delivery on 2026-10-26. The lane owner owns that separately planned work and its safety, review, performance and Windows acceptance checks. No saved path alone authorizes recursive deletion.Validation
Full review path: retries, file deletion, cancellation and failure handling; the architecture plan and reference comparison retained Node’s walker. Five review rounds and bounded correction/readiness checks completed. Fresh CI passed on
7daa1fa56ee4f5d0520fb5eaf61e1c57a279648c, including static analysis/typecheck, all five Node 24 test shards and Windows packaging; the full PR check watcher exited 0 after the remaining platform checks passed.e5a19507be4: 50 passed, 0 failed, 1 skipped across clipboard staging, failed-worktree storage/listing/reload and renderer failure display. The skip is POSIX owner/mode validation. A later test-comment-only commit documents the fake-clock adapter without changing test behavior.cf400fac250carries: held-file failure in 6.374 s; 180.52 s of responsive navigation/resource observation with 3.359 CPU seconds and private memory ending 2.6 MB lower; normal deletion with a real PowerShell terminal open succeeded in 3.142 s, removing the path and shells. These are bounded observations, not a long-term leak or controlled speedup claim.Main-process shutdown that permits a new instance beside an old hung process is outside this PR. Non-shipped scripts/test teardowns retaining async retry options are also outside its scope.