php-http / curl-client

cURL client
http://httplug.io
MIT License
443 stars 28 forks source link

Return value of Http\Client\Curl\PromiseCore::getException() must implement interface Throwable, instance of Nyholm\Psr7\Response #60

Open luckyraul opened 4 years ago

luckyraul commented 4 years ago
PHP message: PHP Fatal error: Uncaught TypeError: Return value of Http\Client\Curl\PromiseCore::getException() must implement interface Throwable, instance of Nyholm\Psr7\Response returned in /var/www/releases/20191015093018/vendor/php-http/curl-client/src/PromiseCore.php:194

Stack trace:
#0 /var/www/releases/20191015093018/vendor/php-http/curl-client/src/CurlPromise.php(103): Http\Client\Curl\PromiseCore->getException()
#1 /var/www/releases/20191015093018/vendor/sentry/sentry/src/Transport/HttpTransport.php(110): Http\Client\Curl\CurlPromise->wait()
#2 /var/www/releases/20191015093018/vendor/sentry/sentry/src/Client.php(117): Sentry\Transport\HttpTransport->send(Object(Sentry\Event))
#3 /var/www/releases/20191015093018/vendor/sentry/sentry/src/Client.php(103): Sentry\Client->captureEvent(Array, Object(Sentry\State\Scope))
qkdreyer commented 4 years ago
TypeError: Return value of Http\Client\Curl\PromiseCore::getException() must implement interface Throwable, instance of Zend\Diactoros\Response returned
#25 /vendor/php-http/curl-client/src/PromiseCore.php(194): Http\Client\Curl\PromiseCore::getException
#24 /vendor/php-http/curl-client/src/CurlPromise.php(103): Http\Client\Curl\CurlPromise::wait
#23 /vendor/sentry/sentry/src/Transport/HttpTransport.php(110): Sentry\Transport\HttpTransport::send
#22 /vendor/sentry/sentry/src/Client.php(117): Sentry\Client::captureEvent
#21 /vendor/sentry/sentry/src/State/Hub.php(146): Sentry\State\Hub::captureEvent
#20 /vendor/sentry/sentry/src/Monolog/Handler.php(73): Sentry\Monolog\Handler::Sentry\Monolog\{closure}
#19 /vendor/sentry/sentry/src/State/Hub.php(87): Sentry\State\Hub::withScope
#18 /vendor/sentry/sentry/src/Monolog/Handler.php(74): Sentry\Monolog\Handler::write
drunken-monkey commented 1 year ago

The problem seems to be in \Http\Client\Curl\PromiseCore::reject(): $this->exception is set to the return value of an onRejected callback, but these are apparently expected to return a response or throw an exception, not to return an exception. (Especially, you definitely cannot rely on them returning an exception, but should at least check if that is the case.) See \Http\Client\Common\Plugin\RetryPlugin::handleRequest() in the php-http/client-common package for an example.

dbu commented 1 year ago

@joelwurtz could you maybe help sort out what would be the correct behaviour?