panther icon indicating copy to clipboard operation
panther copied to clipboard

Tests pass, but throw a FatalError at end (Curl error thrown for http DELETE to /session/xxxxxx)

Open mpiot opened this issue 2 years ago • 6 comments

When I run tests using Panther, all check pass, but the return code is not 0 because a fatal error is thrown at the end. When I run it from my machine this error is reached randomly, on CI machines (self-hosted, github-hosted) it's near 100% of the times.

PHPUnit 9.5.20 #StandWithUkraine

Testing 
..........                                                        10 / 10 (100%)

Time: 02:23.562, Memory: 211.00 MB

OK (10 tests, 71 assertions)

Remaining indirect deprecation notices (11)

  2x: Since gesdinet/jwt-refresh-token-bundle 1.0: The "firewall" node is deprecated without replacement.
    2x in AppWebTestCase::_resetDatabase from App\Tests

  2x: Since gesdinet/jwt-refresh-token-bundle 1.0: The "user_provider" node is deprecated without replacement.
    2x in AppWebTestCase::_resetDatabase from App\Tests

  1x: The "DAMA\DoctrineTestBundle\Doctrine\DBAL\AbstractStaticDriver" class implements "Doctrine\DBAL\VersionAwarePlatformDriver" that is deprecated All drivers will have to be aware of the server version in the next major release.
    1x in PHPUnitExtension::executeBeforeFirstTest from DAMA\DoctrineTestBundle\PHPUnit

  1x: Since gesdinet/jwt-refresh-token-bundle 1.0: The "Gesdinet\JWTRefreshTokenBundle\Entity\AbstractRefreshToken" class is deprecated, use "Gesdinet\JWTRefreshTokenBundle\Model\AbstractRefreshToken" instead.
    1x in AppWebTestCase::_resetDatabase from App\Tests

  1x: The "Symfony\Bridge\Doctrine\Logger\DbalLogger" class implements "Doctrine\DBAL\Logging\SQLLogger" that is deprecated Use {@see \Doctrine\DBAL\Logging\Middleware} or implement {@see \Doctrine\DBAL\Driver\Middleware} instead.
    1x in AppWebTestCase::_resetDatabase from App\Tests

  1x: Method "Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()" might add "array" as a native return type declaration in the future. Do the same in implementation "Stof\DoctrineExtensionsBundle\EventListener\BlameListener" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in AppWebTestCase::_resetDatabase from App\Tests

  1x: Method "Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()" might add "array" as a native return type declaration in the future. Do the same in implementation "Stof\DoctrineExtensionsBundle\EventListener\LoggerListener" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in AppWebTestCase::_resetDatabase from App\Tests

  1x: Method "JsonSerializable::jsonSerialize()" might add "mixed" as a native return type declaration in the future. Do the same in implementation "Facebook\WebDriver\Firefox\FirefoxOptions" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in ProcessControllerE2ETest::testAddStep from App\Tests\Controller\ProductDevelopment\Probe

  1x: The "Facebook\WebDriver\Local\LocalWebDriver::createBySessionID()" method will require a new "bool $isW3cCompliant" argument in the next major version of its parent class "Facebook\WebDriver\Remote\RemoteWebDriver", not defining it is deprecated.
    1x in ProcessControllerE2ETest::testAddStep from App\Tests\Controller\ProductDevelopment\Probe

PHP Fatal error:  Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/27efacf1a6c0ed11e569bc5e75f757e2

Failed to connect to 127.0.0.1 port 9515: Connection refused in /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:333
Stack trace:
#0 /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(585): Facebook\WebDriver\Remote\HttpCommandExecutor->execute()
#1 /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(312): Facebook\WebDriver\Remote\RemoteWebDriver->execute()
#2 /home/mpiot/Documents/apps/vendor/symfony/panther/src/Client.php(582): Facebook\WebDriver\Remote\RemoteWebDriver->quit()
#3 /home/mpiot/Documents/apps/vendor/symfony/panther/src/Client.php(108): Symfony\Component\Panther\Client->quit()
#4 [internal function]: Symfony\Component\Panther\Client->__destruct()
#5 {main}
  thrown in /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php on line 333

Fatal error: Uncaught Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http DELETE to /session/27efacf1a6c0ed11e569bc5e75f757e2

Failed to connect to 127.0.0.1 port 9515: Connection refused in /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:333
Stack trace:
#0 /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(585): Facebook\WebDriver\Remote\HttpCommandExecutor->execute()
#1 /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(312): Facebook\WebDriver\Remote\RemoteWebDriver->execute()
#2 /home/mpiot/Documents/apps/vendor/symfony/panther/src/Client.php(582): Facebook\WebDriver\Remote\RemoteWebDriver->quit()
#3 /home/mpiot/Documents/apps/vendor/symfony/panther/src/Client.php(108): Symfony\Component\Panther\Client->quit()
#4 [internal function]: Symfony\Component\Panther\Client->__destruct()
#5 {main}
  thrown in /home/mpiot/Documents/apps/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php on line 333

mpiot avatar Apr 19 '22 09:04 mpiot

Any insight into what causes this or how to fix it?

gravitiq-cm avatar Aug 18 '22 08:08 gravitiq-cm

Hi, in my case I've do a shell script that handle the execution of phpunit, and override the return code by reading the message of phpunit. This is only a workarround, because don't know why this issue appear.

#/bin/sh
result=$(symfony php vendor/bin/phpunit | tee /dev/stderr)

if echo "$result" | grep -E 'OK \([0-9]+ test'; then
    exit 0;
fi

exit 1

mpiot avatar Aug 18 '22 09:08 mpiot

I'm not using phpunit... I'm just using Symfony\Component\Panther\Client::createFirefoxClient(); and running things from there. It all works, except for the fatal errors at the end (after everything has finished, so I guess related to the destructor or connection closing).

gravitiq-cm avatar Aug 18 '22 11:08 gravitiq-cm

Maybe we could add some setting on Client to tell it not to call $this->webDriver->close() from Client::close()?

gravitiq-cm avatar Aug 18 '22 11:08 gravitiq-cm

Probably related to (or same as): https://github.com/symfony/panther/issues/466

ThomasLandauer avatar Aug 24 '22 12:08 ThomasLandauer

I get around this in my pest tests by doing:

$client = null;

afterEach(function () use (&$client) {
    if ($client !== null) {
        try {
            $client = null;
        } catch (\Throwable $e) {
        }
    }
});

test('some test', function() use (&$client) {
    $client = Client::createChromeClient();
    ...
});

It's odd that I only see this sometimes using panther.

KorvinSzanto avatar Feb 16 '24 20:02 KorvinSzanto