{"record":{"id":"f4df5fc3c4c8ee1d","repo":"tonhowtf/omniget","slug":"download-cancelado-queue","errorCode":null,"errorMessage":"Download cancelado","messagePattern":"Download cancelado","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src-tauri/src/core/queue.rs","lineNumber":1738,"sourceCode":"    }\n    if let Some(hdrs) = opts.extra_headers.clone() {\n        omniget_core::core::ytdlp::register_ext_headers(url.clone(), hdrs);\n    }\n\n    let dl_start = std::time::Instant::now();\n    append_download_log(\n        &app,\n        item_id,\n        format!(\n            \"[omniget] starting download: platform={} title=\\\"{}\\\" url={}\",\n            platform_name, log_title, url\n        ),\n    );\n    let dl_future = async {\n        tokio::select! {\n            r = downloader.download(&info, &opts, tx) => r,\n            _ = cancel_token.cancelled() => {\n                Err(anyhow::anyhow!(\"Download cancelado\"))\n            }\n        }\n    };\n    if let Some(argv) = argv_override.as_ref() {\n        append_download_log(\n            &app,\n            item_id,\n            format!(\n                \"[omniget] running user-edited command ({} args), single attempt\",\n                argv.len()\n            ),\n        );\n    }\n    let result = omniget_core::core::log_hook::CURRENT_ARGV_OVERRIDE\n        .scope(\n            argv_override.clone(),\n            omniget_core::core::log_hook::CURRENT_COOKIE_SLUG.scope(\n                cookie_slug.clone(),","sourceCodeStart":1720,"sourceCodeEnd":1756,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/core/queue.rs#L1720-L1756","documentation":"This error is thrown in the download queue worker when the tokio select! race resolves in favor of the cancellation token instead of the download future. It means the user (or the queue manager) requested cancellation of this download while it was still in flight. The download is aborted and the task completes with this error instead of a result.","triggerScenarios":"cancel_token.cancelled() fires before downloader.download() completes; e.g. the user hits cancel in the UI, the queue is cleared, or the app shuts down while a download is active.","commonSituations":"User cancels a slow or large Bilibili download; queue manager aborts stale entries; window close triggers a graceful shutdown that cancels in-flight downloads.","solutions":["Treat this error as an expected control-flow signal, not a failure: match on the message or use a dedicated Cancelled error type before reporting to the UI","If cancellation is unexpected, check what code calls cancel_token.cancel() (UI handler, queue cleanup) and confirm it should fire at that moment","Ensure partial files from the cancelled download are cleaned up in the same error path"],"exampleFix":"// before\nErr(anyhow::anyhow!(\"Download cancelado\"))\n// after\n#[derive(thiserror::Error, Debug)]\n#[error(\"Download cancelado\")]\npub struct DownloadCancelled;\n// then in the queue loop:\nif e.is::<DownloadCancelled>() { /* mark item as cancelled, not failed */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match queue_result {\n    Err(e) if e.to_string().contains(\"Download cancelado\") => mark_item_cancelled(item),\n    Err(e) => report_failure(item, e),\n    Ok(res) => mark_item_done(item, res),\n}","preventionTips":["Don't cancel downloads unexpectedly; make cancel buttons explicit and confirmed","Model cancellation as a distinct typed error rather than an anyhow string","Clean up partial files on cancellation"],"tags":["cancelation","async","tokio","download"],"backgroundTag":"operation-cancelled","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"}