tonhowtf/omniget · warning

o Reddit está limitando o acesso

Error message

o Reddit está limitando o acesso (HTTP {}). Tente de novo daqui a pouco

What it means

`get_json` retries 429 (Too Many Requests) and 5xx responses with exponential backoff up to `TRIES` attempts. If the last attempt still returns 429 or a server error, it gives up and throws this message telling the user Reddit is rate limiting and to try again later. This is deliberate backoff exhaustion, not an unexpected failure.

Solutions

  1. Wait several minutes before retrying — 429 windows reset over time
  2. Add or increase delays between requests and reduce concurrency to 1
  3. Authenticate with OAuth (client credentials) for a much higher rate limit
  4. Respect the `Retry-After` header the code already parses instead of hammering
  5. Switch network (different IP) if the address is shared and throttled

Example fix

// before
for id in ids {
    let v = client.get_json(&post_url(id)).await?; // hammers the API
}
// after
for id in ids {
    let v = loop {
        match client.get_json(&post_url(id)).await {
            Ok(v) => break v,
            Err(e) if e.to_string().contains("limitando o acesso") => {
                tokio::time::sleep(Duration::from_secs(120)).await;
            }
            Err(e) => return Err(e),
        }
    };
    tokio::time::sleep(Duration::from_secs(7)).await;
}
Defensive patterns

Strategy: retry

Validate before calling

// throttle proactively: never exceed ~1 request / 1.5s unauthenticated
let min_interval = Duration::from_millis(1500);
if last_request.elapsed() < min_interval {
    tokio::time::sleep(min_interval - last_request.elapsed()).await;
}

Try / catch

match client.get_json(url).await {
    Ok(v) => v,
    Err(e) if e.to_string().contains("limitando o acesso") => {
        tokio::time::sleep(Duration::from_secs(300)).await; // cool-down, then retry
        client.get_json(url).await?
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Making more `get_json` calls than Reddit's unauthenticated rate limit allows (roughly 10 req/min without OAuth); running many parallel requests from one IP; the retry loop exhausting all `TRIES` attempts while Reddit keeps returning 429 or 5xx.

Common situations: Bulk-scraping many posts/comments in a tight loop; a shared IP (office/VPN/proxy) already throttled by Reddit; Reddit incidents causing sustained 5xx responses.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/reddit/mod.rs:434

        let mut wait = Duration::from_secs(3);
        for attempt in 1..=TRIES {
            self.pace().await;
            self.requests.fetch_add(1, Ordering::Relaxed);
            let resp = self.client.get(url).send().await;
            match resp {
                Ok(r) if r.status().as_u16() == 403 && attempt < TRIES => {
                    let _ = r.text().await;
                    self.unlock().await?;
                }
                Ok(r) if r.status().is_success() => {
                    let text = r.text().await?;
                    return serde_json::from_str(&text).map_err(|e| {
                        anyhow!("o Reddit respondeu algo que não é JSON ({}): {}", e, url)
                    });
                }
                Ok(r) if r.status().as_u16() == 429 || r.status().is_server_error() => {
                    if attempt == TRIES {
                        return Err(anyhow!(
                            "o Reddit está limitando o acesso (HTTP {}). Tente de novo daqui a pouco",
                            r.status()
                        ));
                    }
                    let retry = r
                        .headers()
                        .get(reqwest::header::RETRY_AFTER)
                        .and_then(|v| v.to_str().ok())
                        .and_then(|v| v.trim().parse::<u64>().ok())
                        .map(Duration::from_secs);
                    tokio::time::sleep(retry.unwrap_or(wait)).await;
                    wait *= 2;
                }
                Ok(r) if r.status().as_u16() == 403 => {
                    return Err(anyhow!(
                        "o Reddit barrou o acesso público (403). Costuma ser bloqueio de rede ou conteúdo restrito: tente de outra conexão"
                    ));
                }

View on GitHub (pinned to 8600b91f42)