tonhowtf/omniget · error · anyhow

tarefa de verificação falhou: {e}

Error message

tarefa de verificação falhou: {e}

What it means

The sha256 verification and file rename run inside `tokio::task::spawn_blocking`; if that spawned task panics (e.g. an unwrapped failure in hashing/rename code, or a panic inside the closure), the JoinError is converted into 'tarefa de verificação falhou: {e}'. It wraps a task-level failure, distinct from the typed checksum/rename errors that propagate through the inner Result.

Solutions

  1. Retry ensure_model; if it follows an app shutdown or cancellation, just re-run the download when the app is idle.
  2. Read the wrapped `{e}` text: 'task panicked' points to a bug in the verify closure — reproduce with the temp file kept and run sha256_of manually.
  3. Check for tokio runtime shutdown during long downloads (e.g. dropping the app window / cancelling the command) and keep the runtime alive until verification completes.

Example fix

// before
let dest = onnx::ensure_model(id, &progress).await?;
// after
let dest = onnx::ensure_model(id, &progress).await.map_err(|e| {
    if e.to_string().contains("tarefa de verificação") {
        anyhow!("verificação do modelo foi interrompida; tente de novo: {e}")
    } else { e }
})?;
Defensive patterns

Strategy: try-catch

Validate before calling

// prevent the common cause (runtime shutdown mid-task): keep the runtime alive
let rt = tokio::runtime::Handle::current();
assert!(!rt.runtime().is_shutting_down(), "runtime encerrando; adie o download");

Try / catch

match onnx::ensure_model(id, &progress).await {
    Err(e) if e.to_string().contains("tarefa de verificação") => {
        eprintln!("verificação interrompida ({e}); repetindo");
        onnx::ensure_model(id, &progress).await
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling `ensure_model` when the spawned blocking task panics — a bug in the closure, panic during sha256_of on an unreadable/truncated temp file, or the runtime shutting down (join on a dropped task) while verification is in flight.

Common situations: App shutdown/cancellation mid-download so the runtime drops the task; OS-level file access surprises during hashing; library bug in the verification closure (should be rare — errors use Result, not panic).

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/7fe79a0760f97711. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/onnx.rs:239

            None,
            Some("conferindo sha256".into()),
        );
        let got = sha256_of(&tmp2)?;
        if got != expected {
            let _ = std::fs::remove_file(&tmp2);
            return Err(anyhow!(
                "o modelo baixado não confere: esperava sha256 {expected}, veio {got}"
            ));
        }
        if dest2.exists() {
            let _ = std::fs::remove_file(&dest2);
        }
        std::fs::rename(&tmp2, &dest2)
            .with_context(|| format!("movendo para {}", dest2.display()))?;
        Ok(())
    })
    .await
    .map_err(|e| anyhow!("tarefa de verificação falhou: {e}"))??;

    super::report(progress, &pid, "done", 1, Some(1), None);
    Ok(dest)
}

/// Apaga um modelo baixado.
pub fn remove_model(id: &str) -> anyhow::Result<()> {
    let path = model_path(id).ok_or_else(|| anyhow!("não achei o diretório de dados do app"))?;
    if path.is_file() {
        std::fs::remove_file(&path).with_context(|| format!("apagando {}", path.display()))?;
    }
    Ok(())
}

/// Quantas threads dar ao ONNX Runtime. Deixa pelo menos um núcleo livre para
/// a interface não travar em lote grande.
fn intra_threads() -> usize {
    std::thread::available_parallelism()

View on GitHub (pinned to 8600b91f42)