Skip to content

Commit

Permalink
Fix retry handling of connection exception (#41811)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdebrauwer authored Apr 3, 2022
1 parent 7d959d5 commit bb071a9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Illuminate/Http/Client/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ public function send(string $method, string $url, array $options = [])
return $this->makePromise($method, $url, $options);
}

$shouldRetry = true;
$shouldRetry = null;

return retry($this->tries ?? 1, function ($attempt) use ($method, $url, $options, &$shouldRetry) {
try {
Expand Down Expand Up @@ -740,8 +740,12 @@ public function send(string $method, string $url, array $options = [])

throw new ConnectionException($e->getMessage(), 0, $e);
}
}, $this->retryDelay ?? 100, function () use (&$shouldRetry) {
return $shouldRetry;
}, $this->retryDelay ?? 100, function ($exception) use (&$shouldRetry) {
$result = $shouldRetry ?? ($this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $exception, $this) : true);

$shouldRetry = null;

return $result;
});
}

Expand Down

0 comments on commit bb071a9

Please sign in to comment.