{"record":{"id":"7fe79a0760f97711","repo":"tonhowtf/omniget","slug":"tarefa-de-verifica-o-falhou-e","errorCode":null,"errorMessage":"tarefa de verificação falhou: {e}","messagePattern":"tarefa de verificação falhou: (.+?)","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/onnx.rs","lineNumber":239,"sourceCode":"            None,\n            Some(\"conferindo sha256\".into()),\n        );\n        let got = sha256_of(&tmp2)?;\n        if got != expected {\n            let _ = std::fs::remove_file(&tmp2);\n            return Err(anyhow!(\n                \"o modelo baixado não confere: esperava sha256 {expected}, veio {got}\"\n            ));\n        }\n        if dest2.exists() {\n            let _ = std::fs::remove_file(&dest2);\n        }\n        std::fs::rename(&tmp2, &dest2)\n            .with_context(|| format!(\"movendo para {}\", dest2.display()))?;\n        Ok(())\n    })\n    .await\n    .map_err(|e| anyhow!(\"tarefa de verificação falhou: {e}\"))??;\n\n    super::report(progress, &pid, \"done\", 1, Some(1), None);\n    Ok(dest)\n}\n\n/// Apaga um modelo baixado.\npub fn remove_model(id: &str) -> anyhow::Result<()> {\n    let path = model_path(id).ok_or_else(|| anyhow!(\"não achei o diretório de dados do app\"))?;\n    if path.is_file() {\n        std::fs::remove_file(&path).with_context(|| format!(\"apagando {}\", path.display()))?;\n    }\n    Ok(())\n}\n\n/// Quantas threads dar ao ONNX Runtime. Deixa pelo menos um núcleo livre para\n/// a interface não travar em lote grande.\nfn intra_threads() -> usize {\n    std::thread::available_parallelism()","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/onnx.rs#L221-L257","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Retry ensure_model; if it follows an app shutdown or cancellation, just re-run the download when the app is idle.","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.","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."],"exampleFix":"// before\nlet dest = onnx::ensure_model(id, &progress).await?;\n// after\nlet dest = onnx::ensure_model(id, &progress).await.map_err(|e| {\n    if e.to_string().contains(\"tarefa de verificação\") {\n        anyhow!(\"verificação do modelo foi interrompida; tente de novo: {e}\")\n    } else { e }\n})?;","handlingStrategy":"try-catch","validationCode":"// prevent the common cause (runtime shutdown mid-task): keep the runtime alive\nlet rt = tokio::runtime::Handle::current();\nassert!(!rt.runtime().is_shutting_down(), \"runtime encerrando; adie o download\");","typeGuard":null,"tryCatchPattern":"match onnx::ensure_model(id, &progress).await {\n    Err(e) if e.to_string().contains(\"tarefa de verificação\") => {\n        eprintln!(\"verificação interrompida ({e}); repetindo\");\n        onnx::ensure_model(id, &progress).await\n    }\n    other => other,\n}","preventionTips":["Don't cancel/drop the async command or shut the tokio runtime down while a model download is in flight.","Retry ensure_model after cancellation — the temp-file flow is restartable.","If it reproduces without shutdown, capture the JoinError text and report as a library bug (the closure should return Err, not panic)."],"tags":["onnx","tokio","task-panic","verification"],"backgroundTag":"thread-interrupted","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}