chilio / laravel-dusk-ci

Docker Test suite for Laravel Dusk in gitlab CI
MIT License
159 stars 51 forks source link

Facebook\WebDriver\Exception\NoSuchDriverException: invalid session id #38

Closed martijnimhoff closed 5 years ago

martijnimhoff commented 5 years ago

Thanks for accepting my PR earlier on!

I'm running into the issue with my Gitlab runner that my tests are failing due to chrome not booting soon enough. This only happens when I run multiple tests in a row (30+). Usually the first few tests succeed and then the rest fails. This is with a testing setup in which I'm repeating the same simple test 100 times:

$this->browse(function (Browser $browser) {
        $browser->visit('/')->assertSee('Hello world!');
});

This is the error I'm getting.

Facebook\WebDriver\Exception\NoSuchDriverException: invalid session id
  (Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 4.14.48-coreos-r2 x86_64)

I'm using these chrome options:

'--window-size=1200,1024',
'--disable-gpu',
'--headless',
'--no-sandbox',

I found that adding a sleep(1); at the end of the setUp()in DuskTestCase.php solves the issue, yet this increases the duration of tests significantly... I might have found a better solution, which is mounting the /dev/shm folder, however I'm not sure how to implement: https://github.com/elgalu/docker-selenium/issues/20

Since adding this fix might increase stability for everyone using Laravel Dusk on a Gitlab CI, I posted this here. @chilio Would you know how to implement this fix?

chilio commented 5 years ago

Hi @martijnimhoff , This seems more like gitlab-runner thing. You can change shm_size in your docker gitlab-runner setup. shm_size = 300000 # in bytes Can you verify if it solves your problem? Let me know...

martijnimhoff commented 5 years ago

Thanks for your response, i've tried it with different sizes. The biggest size I tried was 2GB. Still some of my tests are failing. Also, the amount of failing tests does not change significantly.

try with 2GB (I added those two tests)

Tests: 118, Assertions: 354, Errors: 22.

Earlier test with lower shm_size.

Tests: 116, Assertions: 316, Errors: 24.

This is the output at the end of the tests: Time: 12.25 minutes, Memory: 48.00MB Is this memory usage related to shm?

And is there a way to monitor the actual shm usage?

martijnimhoff commented 5 years ago

Update: Sorry I've been stupid. My runner was using the shared gitlab runner instead of our own runner... I'm closing the issue for now.

erksch commented 4 years ago

I currently have the same issue but when running dusk locally on my Ubuntu 19.04. Like described above, the first two tests pass and the error occurs for the rest of the tests. My /dev/shm is barely used and has 8GB. I am using the same chrome options.

invalid session id
(Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 5.0.10-surface-linux-surface x86_64) (Facebook\WebDriver\Exception\NoSuchDriverException)

Adding sleep(1) to setUp does not work either.

Any ideas?

chilio commented 4 years ago

@erksch Did you verified your gitlab-runner .toml as in https://github.com/laravel/dusk/issues/105#issuecomment-296411919 ?