8000 [HttpClient] Httplug adapter bug with async requests · Issue #37925 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content 8000
[HttpClient] Httplug adapter bug with async requests #37925
Closed
@CthulhuDen

Description

@CthulhuDen

Symfony version(s) affected: 5.1.3

Description
Httplug adapter in symfony/http-client seems to behave incorrectly when some combinations of chaining of promises is used. The example is provided below, where in presence of both ->then combinators script throws GuzzleHttp\Promise\RejectionException: The promise was rejected with reason: Invoking the wait callback did not resolve the promise instead of printing status code. If any of the ->then calls is eliminated the program behaves as expected.

How to reproduce
Run composer require symfony/http-client php-http/httplug nyholm/psr7 guzzlehttp/promises, then execute following script:

<?php

use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpClient\CurlHttpClient;
use Symfony\Component\HttpClient\HttplugClient;

require __DIR__ . '/vendor/autoload.php';

$client = new HttplugClient(new CurlHttpClient());

$sendAsyncRequest = function () use ($client): Http\Promise\Promise {
    return $client->sendAsyncRequest($client->createRequest('GET', 'https://example.com'));
};

$response = $sendAsyncRequest()
    ->then($sendAsyncRequest)
    ->then(function (ResponseInterface $response): ResponseInterface { return $response; })
    ->wait();

echo $response->getStatusCode() . "\n";

Additional context
Bug seems to be somewhere in HttplugClient promises handling as it manifests as well with native and amp http clients.

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

      0