zed-industries/zed · error

Failed to unwrap Mutex

Error message

Failed to unwrap Mutex

What it means

After unwrapping the Arc, run_prediction locks the example's Mutex via into_inner; it fails because the mutex was still locked elsewhere (a task holding the guard leaked or panicked), so exclusive access cannot be obtained.

Solutions

  1. Find and fix the task that retains the mutex guard (often a panicked worker)
  2. Ensure guards are scoped so they drop before prediction finishes
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

        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,
                batched,
                repetition_count,

View on GitHub (pinned to f4178619ac)