tonhowtf/omniget · info

Download cancelled

Error message

Download cancelled

What it means

download_video checks a cancellation token at the start of each retry attempt and bails with "Download cancelled" if it is already cancelled. This is the cooperative-cancellation path: the user or app requested the download to stop.

Solutions

  1. Treat this as an expected control-flow outcome — catch it and surface 'cancelled' to the user, not as a failure.
  2. If unintentional, ensure each download gets its own CancellationToken and don't reuse cancelled ones.
  3. Check no code path cancels the token prematurely (e.g., timeout wrappers or app-close handlers).
Defensive patterns

Strategy: try-catch

Validate before calling

// before starting, ensure the token is fresh
if cancel_token.is_cancelled() {
    cancel_token = CancellationToken::new();
}

Try / catch

match download_video(url, &cancel_token, ...).await {
    Err(e) if e.to_string() == "Download cancelled" => {
        tracing::info!("download cancelled by user"); // not an error for the user
    }
    Err(e) => return Err(e),
    Ok(v) => Ok(v),
}

Prevention

When it happens

Trigger: Calling download_video with a cancel_token that gets cancelled before or between retry attempts — user pressed stop/cancel, app shutdown, or a stale token reused from a previous cancelled operation.

Common situations: User cancels via UI; app teardown cancels all tokens; caller accidentally shares/reuses a token already cancelled for another download.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/ytdlp.rs:3372

        }
        args
    } else {
        Vec::new()
    };

    let max_attempts: usize = 3;
    let mut extra_args: Vec<String> = Vec::new();
    let mut last_error = String::new();
    let mut use_subtitles = should_download_subs;
    let mut use_cfb = !cfb_setting.is_empty() && !explicit_cookie_header && !manual_cookie_enabled;
    let mut format_already_simplified = false;
    let mut last_was_429 = false;

    for attempt in 0..max_attempts {
        tracing::info!("[yt-dlp] download attempt {}/{}", attempt + 1, max_attempts);
        if cancel_token.is_cancelled() {
            tracing::debug!("[perf] download_video took {:?}", _timer_start.elapsed());
            anyhow::bail!("Download cancelled");
        }

        if attempt > 0 {
            let wait: u64 = if last_was_429 {
                match attempt {
                    1 => 3,
                    2 => 8,
                    _ => 15,
                }
            } else {
                1
            };
            tracing::info!(
                "[yt-dlp] retry {}/{} after {}s (429={})",
                attempt,
                max_attempts - 1,
                wait,
                last_was_429

View on GitHub (pinned to 8600b91f42)