Skip to content

fix(server): sweep stale worktree trash dirs via rm -rf subprocess - #7

Merged
connorch merged 1 commit into
mainfrom
t3code/fix-worktree-delete-reconnect
Aug 7, 2026
Merged

connorch merged 1 commit into
mainfrom
t3code/fix-worktree-delete-reconnect

Conversation

@connorch

@connorch connorch commented Aug 7, 2026

Copy link
Copy Markdown
Owner

What Changed

Worktree removal now deletes its rename-aside trash directory with a child rm -rf subprocess instead of fs.rm, and sweeps any other .{name}.removing-<hex> trash directories left behind in the same parent by earlier removals.

Why

Deleting large worktree trees with fs.rm runs the walk on Node's libuv threadpool, which is shared with WebSocket compression and other server file I/O, so a multi-gigabyte tree could starve those. fs.rm also aborts the whole walk on the first file it can't unlink (e.g. macOS App Management denying unlinks inside .app bundles), which could leave a trash directory stranded forever. Shelling out to rm -rf keeps the walk off the threadpool and keeps going past unremovable files, and sweeping the parent directory on each removal cleans up anything stranded by earlier failed deletes.

UI Changes

Not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

- Delete worktree trash directories with a spawned `rm -rf` instead of `fs.remove`, keeping large tree walks off the libuv threadpool and tolerating files rm can't unlink
- Sweep and clean up any stale `.{name}.removing-*` trash dirs left behind by earlier failed removals, not just the one just renamed aside
- Add integration test covering sweep of stale trash directories
@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@connorch
connorch merged commit d27d7b3 into main Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant