Hi @jonnywilliamson ,
Did you find the answer to make retry works with pool?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I'm currently using the Laravel Http Client extensively, and in particular async requests. One item I seem to be noticing is that when my code uses async requests, it seems to ignore the retry option.
So
Http::retry(3)->get('https://httpbin.org/headers');
Will retry correctly if there's an issue but:
Http::pool(fn (Pool $pool) => [
$pool->retry(3)->get('https://httpbin.org/headers'),
$pool->retry(3)->get('https://httpbin.org/headers'),
);
Does not.
Looking into the PendingRequest class I can see where I think the problem begins. Around line half way down the method in the send function, we return early with a promise if the request is to be async just before the retry code is applied to the non-async request.
/**
* Send the request to the given URL.
*
* @param string $method
* @param string $url
* @param array $options
* @return \Illuminate\Http\Client\Response
*
* @throws \Exception
*/
public function send(string $method, string $url, array $options = [])
{
if (! Str::startsWith($url, ['http://', 'https://'])) {
$url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
}
$options = $this->parseHttpOptions($options);
[$this->pendingBody, $this->pendingFiles] = [null, []];
if ($this->async) {
return $this->makePromise($method, $url, $options);
}
$shouldRetry = null;
return retry($this->tries ?? 1, function ($attempt) use ($method, $url, $options, &$shouldRetry) {
try {
Is this intentional? Is there a reason why we can't apply the retry options to an async request. Would that force the promise to need to be resolved first before it could check and therefore negate any benefit of using an async request in the first place?
Just want to check before I go down a large rabbit hole trying to make this work, if anyone knows if this is intentional design or if it's a just something that's been missed.
Thank you.
Please or to participate in this conversation.