8000 Fix retry handling of connection exception (#41811) · laravel/framework@bb071a9 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit bb071a9

Browse files
authored
Fix retry handling of connection exception (#41811)
1 parent 7d959d5 commit bb071a9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Illuminate/Http/Client/PendingRequest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ public function send(string $method, string $url, array $options = [])
708708
return $this->makePromise($method, $url, $options);
709709
}
710710

711-
$shouldRetry = true;
711+
$shouldRetry = null;
712712

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

741741
throw new ConnectionException($e->getMessage(), 0, $e);
742742
}
743-
}, $this->retryDelay ?? 100, function () use (&$shouldRetry) {
744-
return $shouldRetry;
743+
}, $this->retryDelay ?? 100, function ($exception) use (&$shouldRetry) {
744+
$result = $shouldRetry ?? ($this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $exception, $this) : true);
745+
746+
$shouldRetry = null;
747+
748+
return $result;
745749
});
746750
}
747751

0 commit comments

Comments
 (0)
0