Skip to content

Commit

Permalink
Fix Http::retry so that throw is respected for call signature Http::r…
Browse files Browse the repository at this point in the history
…etry([1,2], throw: false) (#684)

* Fix Http::retry so that throw is respected for call signature Http::retry([1,2], throw: false)

* chore: Remove unused Throwable import and update throw_if and throw_unless functions

---------

Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
  • Loading branch information
huangdijia and huangdijia authored Jul 10, 2024
1 parent 099ce07 commit d3a001c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,15 @@ public function send(string $method, string $url, array $options = [])
$response->throw($this->throwCallback);
}

if ($attempt < $this->tries && $shouldRetry) {
$potentialTries = is_array($this->tries) // @phpstan-ignore-line
? count($this->tries) + 1
: $this->tries;

if ($attempt < $potentialTries && $shouldRetry) {
$response->throw();
}

if ($this->tries > 1 && $this->retryThrow) {
if ($potentialTries > 1 && $this->retryThrow) {
$response->throw();
}
}
Expand Down

0 comments on commit d3a001c

Please sign in to comment.