{"record":{"id":"7048297c4dd80586","repo":"stablyai/orca","slug":"failed-to-force-delete-worktree-at-canonicalwork","errorCode":null,"errorMessage":"Failed to force delete worktree at ${canonicalWorktreePath}.","messagePattern":"Failed to force delete worktree at (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktrees.ts","lineNumber":2936,"sourceCode":"                  args.worktreeId,\n                  removedPushTarget,\n                  store,\n                  localWorktreeGitOptions\n                )\n                runtime.clearOptimisticReconcileToken(args.worktreeId)\n                removeWorktreeMetadataAndTransientState(store, args.worktreeId, removalHostId)\n                preservedBranchCleanupByScope.delete(\n                  preservedBranchCleanupScopeKey({\n                    worktreeId: args.worktreeId,\n                    hostId: removalHostId\n                  })\n                )\n                invalidateAuthorizedRootsCache()\n                notifyWorktreesChanged(mainWindow, repoId)\n                removalCompleted = true\n                return {}\n              } else {\n                throw new Error(\n                  formatWorktreeRemovalError(error, canonicalWorktreePath, args.force ?? false)\n                )\n              }\n            }\n            removalCompleted = true\n          } finally {\n            await removalGate.finish(removalCompleted)\n          }\n          await cleanupUnusedWorktreePushTargetRemote(\n            repo.path,\n            args.worktreeId,\n            removedPushTarget,\n            store,\n            localWorktreeGitOptions\n          )\n          rememberPreservedBranchCleanupTarget(\n            args.worktreeId,\n            removalHostId,","sourceCodeStart":2918,"sourceCodeEnd":2954,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktrees.ts#L2918-L2954","documentation":"Thrown in the local removeWorktree catch block when the Git removal error is not recoverable by the Windows recovery path and not an orphan-classified error. formatWorktreeRemovalError with force=true yields the 'Failed to force delete...' prefix plus the underlying Git stderr/stdout. This is the terminal failure after all recovery options are exhausted.","triggerScenarios":"A forced worktrees:remove where `git worktree remove` fails for a reason other than orphan status or a Windows-transient deregistration — e.g. permission error, path-too-long, busy file handle, or filesystem I/O error.","commonSituations":"Windows file handles (editors, terminals, AV) lock files during recursive delete; WSL/Windows path-length limits; permission/ownership issues on the worktree directory; SSH-backed host I/O errors.","solutions":["Close all programs holding files in the worktree (editors, terminals, watchers) and retry.","On Windows/WSL, check for path-too-long or locked handles; retry after releasing them.","Inspect the appended Git stderr in the message for the root cause and address it (permissions, disk, antivirus)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isForceDeleteFailure(e: unknown): boolean {\n  return e instanceof Error && e.message.startsWith('Failed to force delete worktree')\n}","tryCatchPattern":"try {\n  await invoke('worktrees:remove', { worktreeId, force: true })\n} catch (e) {\n  if (isForceDeleteFailure(e)) {\n    // Close programs holding handles, free locks, then surface the appended Git error to the user.\n  } else throw e\n}","preventionTips":["Close editors, terminals, and watchers that hold handles in the worktree before forcing.","On Windows/WSL, watch for path-too-long and locked-handle errors.","Read the appended Git stderr to find the underlying cause (permissions, AV, disk)."],"tags":["worktree-remove","filesystem","windows","force-delete","git-error"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}