Skip to content

Commit

Permalink
Working on trying to recreate issue #36 in testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyamcl committed Apr 8, 2024
1 parent cbec4ce commit cb89c79
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/GuzzleRetryMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ protected function onRejected(RequestInterface $request, array $options): callab
* Decide whether to retry on connect exception
*
* @param array<string,mixed> $options
* @param RequestInterface $request
* @return bool
*/
protected function shouldRetryConnectException(array $options, RequestInterface $request): bool
Expand Down
22 changes: 21 additions & 1 deletion tests/GuzzleRetryMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
];
Expand Down

0 comments on commit cb89c79

Please sign in to comment.