curl-client icon indicating copy to clipboard operation
curl-client copied to clipboard

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

Open luckyraul opened this issue 6 years ago • 3 comments

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))

luckyraul avatar Oct 15 '19 12:10 luckyraul

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

qkdreyer avatar Dec 10 '19 08:12 qkdreyer

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.

drunken-monkey avatar Feb 10 '23 14:02 drunken-monkey

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

dbu avatar Feb 17 '23 16:02 dbu