zed-industries/zed · error

worktree creation was canceled

Error message

worktree creation was canceled

What it means

In restore_worktree_via_git, when no worktree exists at the archived path, git worktree creation is initiated via the main repo and awaited through a receiver; the receiver closed without delivering a result (Repository dropped or creation cancelled), which is reported with this sentinel error meaning the creation never completed rather than that git itself failed.

Solutions

  1. Retry restoration once the main repository is reachable and not mid-mutation
  2. Ensure the detached commit referenced by the archive row still exists in the main repo (git fetch or prune may have removed it)
  3. Keep the temporary project alive until worktree creation finishes
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/agent_ui/src/thread_worktree_archive.rs:677 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/1fec01ccb5d64a27. Report an issue: GitHub.

Appendix: source

Thrown at crates/agent_ui/src/thread_worktree_archive.rs:677

            resolve_git_worktree_to_main_repo(app_state.fs.as_ref(), worktree_path)
                .await
                .is_some();

        if !is_git_worktree {
            let rx = main_repo.update(cx, |repo, _cx| repo.repair_worktrees());
            rx.await
                .map_err(|_| anyhow!("worktree repair was canceled"))?
                .context("failed to repair worktrees")?;
        }
        false
    } else {
        // Create worktree at the original commit — the branch still points
        // here because archival used detached commits.
        let rx = main_repo.update(cx, |repo, _cx| {
            repo.create_worktree_detached(worktree_path.clone(), row.original_commit_hash.clone())
        });
        rx.await
            .map_err(|_| anyhow!("worktree creation was canceled"))?
            .context("failed to create worktree")?;
        true
    };

    let (wt_repo, _temp_wt_project) =
        match find_or_create_repository(worktree_path, remote_connection, cx).await {
            Ok(result) => result,
            Err(error) => {
                remove_new_worktree_on_error(created_new_worktree, &main_repo, worktree_path, cx)
                    .await;
                return Err(error);
            }
        };

    if let Some(branch_name) = &row.branch_name {
        // Attempt to check out the branch the worktree was previously on.
        let checkout_result = wt_repo
            .update(cx, |repo, _cx| repo.change_branch(branch_name.clone()))

View on GitHub (pinned to f4178619ac)