Closed
Description
Symfony version(s) affected: 5.3.4
Description
When streaming responses and a response times out and gets canceled, it should then not throw anymore on __destruct. This works well without RetryableHttpClient, but when that wrapper is used it somehow still throws on __destruct.
How to reproduce
<?php
include 'vendor/autoload.php';
ini_set('error_reporting', -1);
ini_set('display_errors', true);
$client = Symfony\Component\HttpClient\HttpClient::create();
$client = new Symfony\Component\HttpClient\RetryableHttpClient($client);
$client = $client->withOptions([
'timeout' => 0.1,
]);
$resp[] = $client->request('GET', 'http://api.github.com/repos/symfony/symfony');
foreach ($client->stream($resp) as $response => $chunk) {
try {
if ($chunk->isTimeout()) {
$response->cancel();
var_dump('RESP CANCELLED');
}
} catch (Symfony\Contracts\HttpClient\Exception\ExceptionInterface $e) {
var_dump('CAUGHT', $e);
die;
}
}
var_dump('END, NOTHING CAUGHT, SHOULD NOT THROW');
Running this outputs:
string(14) "RESP CANCELLED"
./test.php:30:
string(37) "END, NOTHING CAUGHT, SHOULD NOT THROW"
PHP Fatal error: Uncaught Symfony\Component\HttpClient\Exception\TimeoutException: Idle timeout reached for "http://api.github.com/repos/symfony/symfony". in ./vendor/symfony/http-client/Chunk/ErrorChunk.php:65
The fatal error here is not expected, and commenting out the RetryableHttpClient
fixes it.