zed-industries/zed · error

Failed to unwrap Arc

Error message

Failed to unwrap Arc

What it means

run_prediction tries to take unique ownership of the updated example via Arc::into_inner; it fails when other clones of the Arc still exist (a background task or subscriber hasn't dropped its reference), so the result cannot be unwrapped safely.

Source

Thrown at crates/edit_prediction_cli/src/predict.rs:335

            .actual_patch = actual_patch;

        if ix == repetition_count - 1 {
            let (info, style) = if has_prediction {
                ("predicted", InfoStyle::Normal)
            } else {
                ("no prediction", InfoStyle::Warning)
            };
            step_progress.set_info(info, style);
        }
    }

    ep_store.update(&mut cx, |store, _| {
        store.remove_project(&state.project);
    });
    debug_task.await?;

    *example = Arc::into_inner(updated_example)
        .ok_or_else(|| anyhow::anyhow!("Failed to unwrap Arc"))?
        .into_inner()
        .map_err(|_| anyhow::anyhow!("Failed to unwrap Mutex"))?;
    Ok(())
}

async fn predict_teacher(
    example: &mut Example,
    backend: TeacherBackend,
    batched: bool,
    repetition_count: usize,
    cache_only: bool,
    step_progress: &crate::progress::StepProgress,
) -> anyhow::Result<()> {
    match backend {
        TeacherBackend::Sonnet45 | TeacherBackend::Sonnet46 => {
            predict_anthropic(
                example,
                backend,

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure all background tasks holding the example Arc complete or are dropped before this point
  2. Restructure to avoid sharing the example across tasks
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/edit_prediction_cli/src/predict.rs:335 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/dd58d907ea48d3bb. Report an issue: GitHub.