Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpClient] RetryableHttpClient + streamed responses fails to cancel responses properly #43391

Copy link
Copy link
Closed
@Seldaek

Description

@Seldaek
Issue body actions

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.

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.