From 9eea43ce995b179f4e3ade9d89ec0f1de3a3a634 Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Wed, 25 Mar 2026 09:08:27 +0100 Subject: [PATCH] fix: retry once after 10s on AniList 429 before aborting job On rate limit, wait 10 seconds and retry the same series. If the retry also returns 429, the job stops. Otherwise it continues normally. Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/reading_status_match.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/api/src/reading_status_match.rs b/apps/api/src/reading_status_match.rs index 5f4af06..d1b2783 100644 --- a/apps/api/src/reading_status_match.rs +++ b/apps/api/src/reading_status_match.rs @@ -368,12 +368,27 @@ pub(crate) async fn process_reading_status_match( Ok(Outcome::Ambiguous) => { insert_result(pool, job_id, library_id, series_name, "ambiguous", None, None, None, None).await; } - Err(e) => { - if e.contains("429") || e.contains("Too Many Requests") { - return Err(format!( - "AniList rate limit exceeded (429) — job stopped after {processed}/{total} series" - )); + Err(e) if e.contains("429") || e.contains("Too Many Requests") => { + warn!("[READING_STATUS_MATCH] rate limit hit for '{series_name}', waiting 10s before retry"); + tokio::time::sleep(Duration::from_secs(10)).await; + match search_and_link(pool, library_id, series_name, &token).await { + Ok(Outcome::Linked { anilist_id, anilist_title, anilist_url }) => { + insert_result(pool, job_id, library_id, series_name, "linked", Some(anilist_id), anilist_title.as_deref(), anilist_url.as_deref(), None).await; + } + Ok(Outcome::NoResults) => { + insert_result(pool, job_id, library_id, series_name, "no_results", None, None, None, None).await; + } + Ok(Outcome::Ambiguous) => { + insert_result(pool, job_id, library_id, series_name, "ambiguous", None, None, None, None).await; + } + Err(e2) => { + return Err(format!( + "AniList rate limit exceeded (429) — job stopped after {processed}/{total} series: {e2}" + )); + } } + } + Err(e) => { warn!("[READING_STATUS_MATCH] series '{series_name}': {e}"); insert_result(pool, job_id, library_id, series_name, "error", None, None, None, Some(&e)).await; }