diff --git a/reqwest-retry/src/middleware.rs b/reqwest-retry/src/middleware.rs index d4d5ff2..4f1151a 100644 --- a/reqwest-retry/src/middleware.rs +++ b/reqwest-retry/src/middleware.rs @@ -8,9 +8,6 @@ use reqwest_middleware::{Error, Middleware, Next, Result}; use retry_policies::RetryPolicy; use task_local_extensions::Extensions; -/// We limit the number of retries to a maximum of `10` to avoid stack-overflow issues due to the recursion. -static MAXIMUM_NUMBER_OF_RETRIES: u32 = 10; - /// `RetryTransientMiddleware` offers retry logic for requests that fail in a transient manner /// and can be safely executed again. /// @@ -102,14 +99,11 @@ impl RetryTransientMiddleware { // We classify the response which will return None if not // errors were returned. break match Retryable::from_reqwest_response(&result) { - Some(retryable) - if retryable == Retryable::Transient - && n_past_retries < MAXIMUM_NUMBER_OF_RETRIES => - { + Some(Retryable::Transient) => { // If the response failed and the error type was transient // we can safely try to retry the request. - let retry_decicion = self.retry_policy.should_retry(n_past_retries); - if let retry_policies::RetryDecision::Retry { execute_after } = retry_decicion { + let retry_decision = self.retry_policy.should_retry(n_past_retries); + if let retry_policies::RetryDecision::Retry { execute_after } = retry_decision { let duration = (execute_after - Utc::now()) .to_std() .map_err(Error::middleware)?; diff --git a/reqwest-retry/tests/all/retry.rs b/reqwest-retry/tests/all/retry.rs index 3d18cdb..75bda70 100644 --- a/reqwest-retry/tests/all/retry.rs +++ b/reqwest-retry/tests/all/retry.rs @@ -151,17 +151,6 @@ assert_retry_succeeds!(429, StatusCode::OK); assert_no_retry!(431, StatusCode::REQUEST_HEADER_FIELDS_TOO_LARGE); assert_no_retry!(451, StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS); -// We assert that we cap retries at 10, which means that we will -// get 11 calls to the RetryResponder. -assert_retry_succeeds_inner!( - 500, - assert_maximum_retries_is_not_exceeded, - StatusCode::INTERNAL_SERVER_ERROR, - 100, - 11, - RetryResponder::new(100_u32, 500) -); - pub struct RetryTimeoutResponder(Arc, u32, std::time::Duration); impl RetryTimeoutResponder {