Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dusk Tests won't start after UNgraceful closing #513

Closed
riabiy-denis opened this issue Dec 15, 2022 · 8 comments
Closed

Dusk Tests won't start after UNgraceful closing #513

riabiy-denis opened this issue Dec 15, 2022 · 8 comments

Comments

@riabiy-denis
Copy link

riabiy-denis commented Dec 15, 2022

  • Sail Version: 1.16.3
  • Laravel Version: 9.43
  • PHP Version: 8.1.13
  • Host operating system: Windows / Linux / macOS Ventura 13.0.1 (22A400)

Description AND vague Steps To Reproduce:

It’s defenitely a bug, but I can’t constantly reproduce it, but it’s annoying and stable enough for me to write it here.

If something unsuccessful happens to the test run:

  • I stop it via cmd + C
  • Code has an “infinite pause”, (->pause(10000000...)) and then I close browser window (via VNC)
  • Naturally over time

the test suite gets stuck and won’t start, if I try from an new terminal window.

It says “PHPUnit” and that’s it. Starting with sail dusk.

Just to be clear: overall, everything works as expected after restarting Docker containers. So it’s not a error in my configuration (at least, not an obvious one). I can easily run +150 tests reliably and consistently. But during development I’m quite annoyed having to restart from time to time.

Is that how it suppose to work? Or I could do something, but restart docker containers.


p.s. 3-5y ago I'd use this snippet before starting, but now getAllSessions is deprecated due to security reasons and I'm sad

collect(RemoteWebDriver::getAllSessions(config('some_hot_config'))->each(function ($session) {
    RemoteWebDriver::createBySessionID($session['id'], config('some_hot_config'))->quit();
});

Log

Waited long enough, wanted to reproduce and attach a screenshoot and seems like 15 minutes after this is what I see

vendor/bin/sail dusk
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.

E

Time: 15:00.782, Memory: 32.00 MB

There was 1 error:

1) Tests\Browser\ExampleTest::test_landing_page_visible
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--window-size=1920,1080","--disable-gpu","--headless"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"args":["--window-size=1920,1080","--disable-gpu","--headless"]}}}

Operation timed out after 180001 milliseconds with 0 bytes received

/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:346
/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:134
/var/www/html/tests/DuskTestCase.php:65
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:219
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php:247
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:220
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:98
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:66
/var/www/html/tests/Browser/ExampleTest.php:20

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
make: *** [test] Error 2

After restart everything works as expected, ofc.

@github-actions
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@riabiy-denis
Copy link
Author

riabiy-denis commented Dec 20, 2022

@driesvints by any means I don't want to annoy you, but if you could give me hints on what to "poke", you are welcome : D
My main take is "do you observe it too on fresh instances" or I should keep digging?

I understand what's going on in Sail (overall) and see nothing specific in Sail or Dusk.

Some additional points:

  • Sail just orchestrates starting up and passes some env vars
  • Dusk on successful fail closes all the sessions, that it has opened (vey important caveat) and during successful flow it's sufficient. If something goes wrong -> it doesn't, BUT it should not prevent opening new ones. Somewhat a memory leak, but I don't care.
  • Gave 8Gb of memory and 6CPUs. Don't see it as a bottleneck. My colleague gave more, same : D
  • Issue persists (and somewhat more prominent) on ARM M1Pro too.

BTW, Docker is v4.12.0. because of this issue, that literally crashes Selenium containers on anything higher.

@driesvints
Copy link
Member

Heya sorry but this seems like a very specific use case. I have no idea what might be going wrong here. It might be better to try a support channel as well?

@riabiy-denis
Copy link
Author

@driesvints no problems, I'll close my issue, BUT could you check one thing

  • fresh laravel/sail setup
  • simple dusk test
  • ->pause(1000000000) (some long number, hours)
  • ctr + c
  • new sail dusk run

Because my setup is as close to native, as possible.
And do that IDK, 2-3 times.

Do you observe that locally?
Or do I understand correctly, that you have not seen such behaviour at all?

I'm trying to understand, if it's normal or not : D
Don't want to fight windmills.

@riabiy-denis
Copy link
Author

I think this could be the answer. (--no-sandbox)

laravel/dusk#488

Will give it a few days and will ask colleagues from the ARM-squad. If all fine -> I'll close the issue on my own with a feedback.

BTW, thanks for not closing the issue "just cause" : )

@riabiy-denis
Copy link
Author

It did NOT help. Have no idea on what could be done. Closing the issue, without solution.

@mathieufrh
Copy link

Hello @riabiy-denis I have the exact same problem. Have you find a solution since your last message ?

@riabiy
Copy link

riabiy commented Jun 28, 2024

Hello @riabiy-denis I have the exact same problem. Have you find a solution since your last message ?

Yes. You need to increase the amount of sessions available to Selenium container. And set a timeout. This will give you a pool big enough to do mistakes and not to have restart the whole container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants