Skip to content

Commit b12d8ac

Browse files
committed
adjust decider to not retry client errors
1 parent 14a2a39 commit b12d8ac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Plugin/RetryPlugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Http\Client\Common\Plugin;
66
use Http\Client\Exception;
7+
use Http\Client\Exception\HttpException;
78
use Http\Promise\Promise;
89
use Psr\Http\Message\RequestInterface;
910
use Psr\Http\Message\ResponseInterface;
@@ -56,7 +57,8 @@ public function __construct(array $config = [])
5657
$resolver->setDefaults([
5758
'retries' => 1,
5859
'decider' => function (RequestInterface $request, Exception $e) {
59-
return true;
60+
// do not retry client errors
61+
return !($e instanceof HttpException && $e->getCode() < 500);
6062
},
6163
'delay' => __CLASS__.'::defaultDelay',
6264
]);

0 commit comments

Comments
 (0)