Skip to content

Fix worktree removal timing out on large install trees#3902

Open
jakeleventhal wants to merge 4 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/fix-worktree-remove-timeout
Open

Fix worktree removal timing out on large install trees#3902
jakeleventhal wants to merge 4 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/fix-worktree-remove-timeout

Conversation

@jakeleventhal

@jakeleventhal jakeleventhal commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Solves #3593

  • Forced worktree removal was hitting a 15s git worktree remove timeout on multi-GB trees with setup artifacts like node_modules.
  • Delete the working tree via the filesystem first (5m budget), then let git clean up registration metadata with a longer timeout.
  • Update the worktree remove integration test to exercise the force path used by thread deletion.

Test plan

  • Delete a thread that owns a worktree with installed deps and choose “Delete the worktree too”
  • Confirm the toast no longer reports Git command timed out / worktree removal failure
  • Confirm the worktree directory is gone under ~/.t3/worktrees/... and git worktree list no longer lists it
  • vp test in apps/server for src/vcs/GitVcsDriverCore.test.ts

Made with Cursor

Note

Fix removeWorktree timing out on large install trees by pre-deleting directories with retry

  • When force=true, removeWorktree now pre-deletes the worktree directory before running git worktree remove, avoiding git's own slow recursive delete on large trees.
  • Directory deletion only proceeds if the target is a registered linked worktree (verified via git worktree list --porcelain), preventing accidental deletion of unregistered paths.
  • Transient filesystem errors (Busy, WouldBlock, Unknown) are retried on a spaced schedule (100ms intervals, up to 50 attempts); persistent failures surface as GitCommandError.
  • A 5-minute timeout guards the entire directory-delete phase; the subsequent git worktree remove runs with a 60-second timeout.
  • Behavioral Change: removeWorktree(force=true) now performs two filesystem/git operations instead of one, and timeout or delete failures surface as structured GitCommandError rather than a hung process.

Macroscope summarized 6c52ef2.

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>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c3ff8123-3722-4456-a4bf-b1a67764eeb8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jul 11, 2026
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
@macroscopeapp

macroscopeapp Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f4844dc. Configure here.

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
jakeleventhal and others added 2 commits July 11, 2026 19:48
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>
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant