You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Worktree bootstrap failures leak orphaned directories causing disk fillup #14648
When Worktree.create fails during its deferred bootstrap phase (the setTimeout(..., 0) at line 357 of packages/opencode/src/worktree/index.ts), no cleanup runs. The synchronous setup that already completed — directory creation, git worktree add, git branch, and Project.addSandbox() — is left behind permanently.
There are three failure points that all have this problem:
Unexpected exception in the outer start() promise (line 411-413) — logs, no cleanup
Each failed attempt generates a unique random name (brave-cabin, calm-cactus, etc.), so retries never reuse the previous directory. Every failure leaves behind:
A worktree directory at ~/.local/share/opencode/worktree/<project-id>/<name>/ containing a full repo clone
A git worktree entry in .git/worktrees/
A git branch opencode/<name>
A sandbox record in the project database
There is no startup garbage collection, no periodic pruning, and no detection of orphaned worktrees. For a large repo, each orphan can be hundreds of MB. Users experiencing repeated bootstrap failures (network issues, disk pressure, permission errors) will see unbounded disk consumption until the volume fills up.
Plugins
None
OpenCode version
Latest // v1.2.10
Steps to reproduce
Open a git repository in opencode
Create a worktree (any method that triggers Worktree.create)
Have the bootstrap fail — this can happen due to network issues, disk pressure, permission errors, or a corrupt repo state causing git reset --hard or Instance.provide() to fail
Observe that the worktree directory remains at ~/.local/share/opencode/worktree/<project-id>/<random-name>/
Run git worktree list in the parent repo — the orphaned entry is still registered
Run git branch -a | grep opencode/ — the orphaned branch is still present
Retry creating a worktree — a new random name is generated, the previous orphan is never cleaned up
Repeat — each failure adds another full repo clone to disk with no upper bound
Activity
github-actions commentedon Apr 24, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.