From 487839640f79c4b55cff4931b472ff9aea685ee1 Mon Sep 17 00:00:00 2001 From: ntohidi Date: Tue, 2 Sep 2025 16:49:01 +0800 Subject: [PATCH] fix: raise error on last attempt failure in perform_completion_with_backoff. ref #989 --- crawl4ai/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crawl4ai/utils.py b/crawl4ai/utils.py index a871bc91..046351e7 100644 --- a/crawl4ai/utils.py +++ b/crawl4ai/utils.py @@ -1790,6 +1790,10 @@ def perform_completion_with_backoff( except RateLimitError as e: print("Rate limit error:", str(e)) + if attempt == max_attempts - 1: + # Last attempt failed, raise the error. + raise + # Check if we have exhausted our max attempts if attempt < max_attempts - 1: # Calculate the delay and wait