Fix worktree removal timing out on large install trees#3902
Fix worktree removal timing out on large install trees#3902jakeleventhal wants to merge 5 commits into
Conversation
Force-remove deletes the working tree via the filesystem first so git only cleans registration metadata, instead of timing out while walking multi-GB node_modules. Co-authored-by: Cursor <cursoragent@cursor.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This bug fix introduces substantial new filesystem manipulation logic (~80 lines) for pre-deleting worktree directories with retry handling and safety validation. While the intent is clear and tests are comprehensive, the complexity of the new behavior warrants human review. You can customize Macroscope's approvability policy. Learn more. |
Only wipe the directory after confirming the path is a linked entry from `git worktree list`, so mistyped or non-worktree paths are left intact. Co-authored-by: Cursor <cursoragent@cursor.com>
If listing times out or fails, skip the filesystem pre-delete and still run git worktree remove instead of aborting the whole operation. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 35a62d9. Configure here.
| onSome: () => Effect.void, | ||
| }), | ||
| ), | ||
| ); |
There was a problem hiding this comment.
FS failure skips git cleanup
Medium Severity
When force pre-delete fails or times out, removeWorktree returns that error and never runs git worktree remove. Directory wipe can already be partial or complete by then, so git registration metadata is left behind even though that second step is what the change relies on for cleanup. List failures correctly fall through to git; filesystem-phase failures do not.
Reviewed by Cursor Bugbot for commit 35a62d9. Configure here.


Summary
Solves #3593
git worktree removetimeout on multi-GB trees with setup artifacts likenode_modules.Test plan
Git command timed out/ worktree removal failure~/.t3/worktrees/...andgit worktree listno longer lists itvp testinapps/serverforsrc/vcs/GitVcsDriverCore.test.tsMade with Cursor
Note
Fix
removeWorktreetiming out on large install trees by pre-deleting directories with retryforce=true,removeWorktreenow pre-deletes the worktree directory before runninggit worktree remove, avoiding git's own slow recursive delete on large trees.git worktree list --porcelain), preventing accidental deletion of unregistered paths.Busy,WouldBlock,Unknown) are retried on a spaced schedule (100ms intervals, up to 50 attempts); persistent failures surface asGitCommandError.git worktree removeruns with a 60-second timeout.removeWorktree(force=true)now performs two filesystem/git operations instead of one, and timeout or delete failures surface as structuredGitCommandErrorrather than a hung process.Macroscope summarized 35a62d9.