xai-org/grok-build · warning

cancelled during ignored-only copy

Error message

cancelled during ignored-only copy

What it means

`copy_ignored_only` copies git-ignored files from source to dest in parallel using `copy_parallel`. Since `copy_parallel` returns Ok with partial stats when the cancellation token fires, this function explicitly checks the token afterwards and bails so an interrupted copy is never reported as success. Hitting this error means the copy was cancelled partway through.

Source

Thrown at crates/codegen/xai-fast-worktree/src/api.rs:538

        let start = std::time::Instant::now();
        let unignored_paths = crate::copy::collect_unignored_paths(source, num_workers)?;

        let copy_config = ParallelCopyConfig {
            num_workers,
            channel_buffer: self.channel_buffer,
            skip_files: Some(Arc::new(unignored_paths)),
            respect_gitignore: false,
            skip_patterns,
        };

        let copy_result =
            crate::copy::copy_parallel(source, dest, copy_config, self.cancellation_token.clone())?;

        // `copy_parallel` returns Ok with partial stats on cancellation; surface
        // it so an interrupted copy isn't treated as success.
        if self.cancellation_token.is_cancelled() {
            anyhow::bail!("cancelled during ignored-only copy");
        }

        tracing::debug!(
            elapsed = ?start.elapsed(),
            files = copy_result.stats.files_copied,
            dirs = copy_result.stats.dirs_created,
            symlinks = copy_result.stats.symlinks_copied,
            skipped = copy_result.stats.files_skipped,
            "copying ignored files (ignored-only) complete"
        );

        Ok(copy_result.stats.into())
    }
}

/// Error context attached when worktree creation fails on a full disk. The
/// pager matches on it, so this constant is the cross-crate contract.
pub const OUT_OF_DISK_CONTEXT: &str = "not enough free disk space";

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Check what cancelled the shared `CancellationToken` (user abort, timeout, upstream failure) before retrying.
  2. Create/obtain a fresh, non-cancelled token (e.g. `CancellationToken::new()` or a child token from an uncancelled parent) and re-run `copy_ignored_only`.
  3. Verify dest state after cancellation — the copy is partial — and either delete the partial dest or make the retry idempotent (copy_parallel overwrites).
  4. If cancellation was unintended, fix the owner of the token (don't cancel a token shared across unrelated operations).
  5. Prefer the structured cancellation result: treat this error as 'operation cancelled', not a copy bug.

Example fix

// before
let token = shared_token; // already cancelled by a previous op
api.copy_ignored_only(&src, &dst, &token)?;
// after
let token = CancellationToken::new(); // fresh token for this operation
match api.copy_ignored_only(&src, &dst, &token) {
    Err(e) if e.to_string().contains("cancelled during ignored-only copy") => {
    fs::remove_dir_all(&dst).ok(); // discard partial copy
    // retry or propagate as Canceled
    }
    other => other?,
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the token isn't already cancelled before starting.
if cancellation_token.is_cancelled() {
    // create a fresh token or abort early instead of a doomed copy
cancellation_token = CancellationToken::new();
}

Try / catch

match api.copy_ignored_only(&src, &dst, &token) {
    Err(e) if e.to_string().contains("cancelled during ignored-only copy") => {
    fs::remove_dir_all(&dst).ok(); // clean partial output
    return Err(OperationCancelled);
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling `copy_ignored_only` while (or before) the shared `CancellationToken` is cancelled — e.g. the user aborts the operation, a parent task times out, or the token was cancelled earlier and never reset.

Common situations: User-initiated cancellation of a session/worktree sync; shutdown or timeout logic cancelling the token mid-copy; reusing a token that was cancelled by a previous failed operation; slow/large ignored-file trees increasing the window for cancellation.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/4aec2d07be665661. Report an issue: GitHub.