claude-code - 💡(How to fix) Fix [Bug] "Remove this worktree" button silently fails after commits; exit prompt sometimes missing [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48751Fetched 2026-04-16 06:51:59
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2

Error Message

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/albert/.local/share/claude/versions/2.1.109 (expected in multi-process scenarios)\n at yU_ (/$bunfs/root/src/entrypoints/cli.js:2342:2153)\n at Vs6 (/$bunfs/root/src/entrypoints/cli.js:2342:1233)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:07:59.564Z"},{"error":"Error: ECONNREFUSED\n at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n at emitError (node:events:43:23)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n at emitError (node:events:43:23)\n at <anonymous> (node:_http_client:253:22)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:14.583Z"},{"error":"Error: ECONNREFUSED\n at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n at emitError (node:events:43:23)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n at emitError (node:events:43:23)\n at <anonymous> (node:_http_client:253:22)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:55.600Z"},{"error":"Error: ECONNREFUSED\n at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n at emitError (node:events:43:23)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n at emitError (node:events:43:23)\n at <anonymous> (node:_http_client:253:22)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:09:18.518Z"},{"error":"Error: ECONNREFUSED\n at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n at emitError (node:events:43:23)\n at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n at emitError (node:events:43:23)\n at <anonymous> (node:_http_client:253:22)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/src/entrypoints…

Code Example

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/albert/.local/share/claude/versions/2.1.109 (expected in multi-process scenarios)\n    at yU_ (/$bunfs/root/src/entrypoints/cli.js:2342:2153)\n    at Vs6 (/$bunfs/root/src/entrypoints/cli.js:2342:1233)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:07:59.564Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:14.583Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:55.600Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:09:18.518Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints…
RAW_BUFFERClick to expand / collapse

Bug Description

The end-of-session "Remove this worktree" button fails silently any time HEAD has moved from the original commit recorded at worktree creation. The internal check compares current HEAD against originalHeadCommit and returns errorCode:4 before git worktree remove is ever attempted — the user sees nothing happen.

This makes the feature nearly useless in practice: the entire point of a worktree is to do work in it, and doing work means committing. Once you've committed (even if pushed and merged), the only path to remove the worktree is to shell out to git worktree remove --force manually.

Separate issue: the exit prompt sometimes doesn't appear at all at session end, even when the session is clearly in a worktree (created via EnterWorktree earlier in the session). The prompt-gating logic checks currentSessionWorktree !== null, but this flag appears to get cleared or lost under some conditions — after long sessions, after compaction, or after background agents run. When this happens there's no way to reach the Remove/Keep choice at all; the session just prints a farewell and exits, leaving the worktree behind silently.

Expected behavior:

  1. The Remove button should succeed when the branch is clean and pushed to its upstream (even with commits ahead of the original HEAD). It's safe — nothing is lost.
  2. git checkout <otherbranch> inside the worktree should also not block removal.
  3. If there are genuinely uncommitted/unpushed changes, either (a) surface the error inline with a "Remove anyway" option, or (b) gate on working-tree cleanliness + upstream-tracking state rather than originalHeadCommit equality.
  4. The exit prompt should appear reliably whenever the session was created in or entered a worktree, regardless of conversation length or background agent activity.

At minimum: surface the error instead of silently no-oping. Silent failures plus missing prompts are the worst UX combination.

Repro (no-op): create a worktree with EnterWorktree, commit any change, push, click "Remove this worktree" at session end — nothing happens.

Repro (missing prompt): less reproducible; happens intermittently on long worktree sessions.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.109
  • Feedback ID: cab63afa-b597-45f2-91dd-7624d128c298

Errors

[{"error":"Error: NON-FATAL: Lock acquisition failed for /Users/albert/.local/share/claude/versions/2.1.109 (expected in multi-process scenarios)\n    at yU_ (/$bunfs/root/src/entrypoints/cli.js:2342:2153)\n    at Vs6 (/$bunfs/root/src/entrypoints/cli.js:2342:1233)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:07:59.564Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:14.583Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:08:55.600Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints/cli.js:117:2467)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-15T19:09:18.518Z"},{"error":"Error: ECONNREFUSED\n    at from (/$bunfs/root/src/entrypoints/cli.js:107:7862)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:115:12925)\n    at emitError (node:events:43:23)\n    at <anonymous> (/$bunfs/root/src/entrypoints/cli.js:114:1149)\n    at emitError (node:events:43:23)\n    at <anonymous> (node:_http_client:253:22)\n    at processTicksAndRejections (native:7:39)\n    at request (/$bunfs/root/src/entrypoints…

Note: Content was truncated.

extent analysis

TL;DR

The "Remove this worktree" button fails silently when the HEAD has moved from the original commit, and the exit prompt sometimes doesn't appear, causing issues with worktree removal.

Guidance

  • Modify the internal check to compare the current HEAD against the original HEAD commit, considering the branch cleanliness and upstream tracking state instead of exact equality.
  • Implement error handling to surface the error inline with a "Remove anyway" option when there are uncommitted or unpushed changes.
  • Ensure the exit prompt appears reliably by checking the current session worktree flag and handling cases where it might get cleared or lost.
  • Verify the fix by creating a worktree, committing changes, pushing, and clicking "Remove this worktree" to ensure it succeeds or prompts for confirmation.

Example

No specific code snippet can be provided without modifying the existing codebase, but the logic for checking the worktree removal conditions could be updated to consider the branch cleanliness and upstream tracking state.

Notes

The provided error logs seem unrelated to the main issue, as they mention lock acquisition failures and ECONNREFUSED errors, which might be separate issues. The solution should focus on updating the internal check and error handling for worktree removal.

Recommendation

Apply a workaround by manually using git worktree remove --force when the "Remove this worktree" button fails, and consider updating the internal check logic to handle branch cleanliness and upstream tracking state for a more robust solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [Bug] "Remove this worktree" button silently fails after commits; exit prompt sometimes missing [2 comments, 2 participants]