From cb89c79974dbf7edf444c0fe162956949beb282c Mon Sep 17 00:00:00 2001 From: Casey McLaughlin Date: Mon, 8 Apr 2024 12:56:02 -0400 Subject: [PATCH] Working on trying to recreate issue #36 in testing. --- src/GuzzleRetryMiddleware.php | 1 + tests/GuzzleRetryMiddlewareTest.php | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/GuzzleRetryMiddleware.php b/src/GuzzleRetryMiddleware.php index 55706b0..41f7e40 100644 --- a/src/GuzzleRetryMiddleware.php +++ b/src/GuzzleRetryMiddleware.php @@ -231,6 +231,7 @@ protected function onRejected(RequestInterface $request, array $options): callab * Decide whether to retry on connect exception * * @param array $options + * @param RequestInterface $request * @return bool */ protected function shouldRetryConnectException(array $options, RequestInterface $request): bool diff --git a/tests/GuzzleRetryMiddlewareTest.php b/tests/GuzzleRetryMiddlewareTest.php index 977dd9d..136c604 100644 --- a/tests/GuzzleRetryMiddlewareTest.php +++ b/tests/GuzzleRetryMiddlewareTest.php @@ -747,7 +747,27 @@ public function testGiveUpAfterSecsFailsWhenTimeLimitExceeded(): void $responses = [ new Response(429, [], 'Wait 1'), new Response(429, [], 'Wait 2'), - new Response(429, [], 'Wait 3'), + new Response(503, [], 'Wait 3'), + new Response(429, [], 'Wait 4'), + new Response(200, [], 'Good') + ]; + + $stack = HandlerStack::create(new MockHandler($responses)); + $stack->push(GuzzleRetryMiddleware::factory([ + 'default_retry_multiplier' => 1.5, + 'give_up_after_secs' => 1 + ])); + + $client = new Client(['handler' => $stack]); + $client->request('GET', '/'); + } + + public function testGiveUpAfterSecsWithLongerTimes(): void + { + $responses = [ + new Response(429, [], 'Wait 1'), + new Response(429, [], 'Wait 2'), + new Response(503, [], 'Wait 3'), new Response(429, [], 'Wait 4'), new Response(200, [], 'Good') ];