Skip to content

fix(cli): retry Windows worktree cleanup locks - #9603

Merged
alex-alecu merged 4 commits into
mainfrom
fix/windows-worktree-cleanup-retry
Apr 28, 2026
Merged

fix(cli): retry Windows worktree cleanup locks#9603
alex-alecu merged 4 commits into
mainfrom
fix/windows-worktree-cleanup-retry

Conversation

@alex-alecu

@alex-alecu alex-alecu commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Followup for #9600

  • Make Windows worktree and temp-directory cleanup tolerant of transient file-lock errors.
  • Keep the implementation in Kilo-specific helpers, with only small annotated hook points in shared OpenCode files.

Why

This is both a real cleanup bug and a test reliability bug: Worktree.remove can hit the same slow Windows handle-release race in normal worktree removal, while CI also exposed it during test temp-directory teardown after otherwise-passing tests.

We know that from the failure split: some failures came from the production worktree removal path (git worktree remove / directory cleanup), and others came only from global test cleanup (EACCES/EBUSY deleting opencode-test-data-*).

Upstream

I checked anomalyco/opencode dev, recent PRs/issues, and code for an equivalent EBUSY/EACCES/EPERM worktree cleanup fix. I did not find an upstream fix to port.

Upstream currently has similar cleanup assumptions, but its recent Windows unit runs are passing; this appears to be a latent Windows race that Kilo hits more often because we run extra worktree/session tests and branch CI combinations.

@kilo-code-bot

kilo-code-bot Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (7 files)
  • .changeset/windows-worktree-cleanup.md
  • packages/opencode/src/kilocode/worktree-cleanup.ts
  • packages/opencode/src/worktree/index.ts
  • packages/opencode/test/fixture/fixture.ts
  • packages/opencode/test/kilocode/cleanup.ts
  • packages/opencode/test/kilocode/worktree-remove-lock.test.ts
  • packages/opencode/test/preload.ts

Reviewed by gpt-5.5-2026-04-23 · 365,523 tokens

@alex-alecu
alex-alecu merged commit 3a254d0 into main Apr 28, 2026
19 checks passed
@alex-alecu
alex-alecu deleted the fix/windows-worktree-cleanup-retry branch April 28, 2026 11:02
jliounis pushed a commit to jliounis/kilocode that referenced this pull request May 18, 2026
…leanup-retry

fix(cli): retry Windows worktree cleanup locks
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…leanup-retry

fix(cli): retry Windows worktree cleanup locks
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.

2 participants