Skip to content

[HttpClient] Timeout or max_duration not honored #49113

@peter17

Description

@peter17

Symfony version(s) affected

6.2.5

Description

I observe a regression in v6.2.5: #44544 was fixed and is now happening again.

How to reproduce

<?php

use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\Exception\TransportException;
use Symfony\Component\Stopwatch\Stopwatch;

require_once __DIR__.'/vendor/autoload_runtime.php';

$client = HttpClient::create();
$stopwatch = new Stopwatch();

$stopwatch->start('not parallel');
try {
    $client->request('GET', 'http://10.255.255.1', ['timeout' => 5]);
} catch (TransportException) {
    echo ".";
}
echo "\n".$stopwatch->stop('not parallel')."\n";

$stopwatch->start('parallel');
$requests = [];
for ($i = 0; $i < 10; $i++) {
    $requests[] = $client->request('GET', 'http://10.255.255.1', ['timeout' => 5]);
}
foreach ($requests as $response) {
    try {
        $response->getContent();
    } catch (TransportException) {
        echo ".";
    }
}
echo "\n".$stopwatch->stop('parallel')."\n";

The output is:

.
default/not parallel: 8.00 MiB - 5009 ms
..........
default/parallel: 8.00 MiB - 50053 ms

But the last value should be around 5 s not 50 s.

Thanks!

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions