-
Notifications
You must be signed in to change notification settings - Fork 28
Session is not cleaning up all chromedriver processes #28
Comments
Further testing shows this does not happen when you manually start the standalone jar before running the tests. |
I am seeing the same issue with multiple specs. As a workaround, I set the Chrome capability
|
Interesting if that works. This might be acceptable for smaller projects, but when you have a large collection, this would slow things down a lot if you are use to running 3 or more parallel instances.. That said, it might work for me for now, but won't be a sustainable workaround for long. |
Yup I'm running into this same issue as well, and setting |
The workaround does not work for me. |
A workaround, which is not ideal but works for me, is to use shelljs to run a kill command, in the shell.exec('taskkill /FI "IMAGENAME eq 2.33-x64-chromedriver" /F') |
I'm using chromedriver 2.33-x64 through the `services: [ 'selenium-standalone' ] and the chromedriver instances do not stop themselves even if I set maxInstances to 1.
in my package.json:
|
@rgustavsson so it's more an issue of the selenium-standalone service? |
@christian-bromann not sure. @Gary-Osteen-Q2 mentioned:
So I was assuming that it works when running the selenium-standalone service manually. |
Bumping this. Any thoughts on what might be causing this yet? It's causing issues on our build servers as we get up to 100+ running instances of chromedriver! Plus it means we can't clean down the workspace between builds because of the same said running process. |
I have experienced this on both Chrome and Firefox with its geckodriver |
Me too. On Windows and Mac. Really problematic. |
Tried to do some research on this (on Windows). It seems that Seems like an issue in selenium-standalone, however I can't find anyone reporting it there, so maybe something specific in how it is invoked? |
@ashmind did you find anything new? Debugging this morning to see what's up. |
I just tried putting a:
and it seems to fix it, no more chromedriver left behind. |
mhm .. but why did it fix it when we wait in the afterHook? |
False alert 😅 I still get the idle at the end.. @christian-bromann any workaround you could think of or info I could gather? |
no idea, something must be up when trying to kill these processes |
@FlippieCoetser's solution seems to be the thing to do for now 🙏 |
Hi , I am also facing the same issue.. @christian-bromann @phil-lgr is there any solution for it? |
@amolebhojane sorry but I can't look into this atm, any PRs or suggestion for fixes are highly appreciated |
I reproduced the problem using just I use a short delay after uninitializing the WebdriverIO client as a workaround to get the const webdriverio = require('webdriverio')
const client = webdriverio.remote({...})
client.init()
...
.end()
// the following line helps stopping the chromedriver process after
// killing the selenium process returned by the start method
.pause(100) |
Ran into this today as well, as a workaround I've simply added this as an npm posttest command |
I've been running this as a post npm script:
|
I am having a similar issue. But I am also having the issue where the first test fails with the Connection Reset error. There were no lingering chromedriver sessions open. I run my tests and the first chrome test fails. This started all of a sudden too. I was having no failures and now it just keeps failing. |
Works fine against saucelabs because each test is run on its own machine. It's only when I run these locally. |
Hi guys. |
I've tried all of the suggestions mentioned above and received inconsistent results. The only way I've gotten it to work consistently is by adding these lines to wdio.conf.js:
I don't have a good explanation. Putting |
afterSession: async function(){
// workaround to make sure the chromedriver shuts down
await browser.end().pause(1000);
},
after: async function(){
// workaround to make sure the chromedriver shuts down
await browser.pause(1000);
} I had to add the async and await bits, then it started working for me to clean them up reliably. |
Is this the accepted workaround for this issue? |
@silne30 my last comment is the simplest workaround for the issue and I hope it works for you. I'm not sure if I should close this as it isn't fixed. |
@Gary-Osteen-Q2 I tested and can confirm, your workaround works. |
I've added the workaround to the top to save someone else time until this issue gets fixed. |
For this workaround, do we have to be running the tests as Async for it to work? |
No. I run it in sync mode. Just the function in the wdio.config.js file needs the aysnc/await tags for it to work and actually wait. |
Hmmm....those hooks didn't work for me. Still getting the Connection reset by peer or cannot write to server errors. I wonder if it has something to do with my setup. |
If you start the wdio runner programmatically using the wdio launcher (const wdio = new Launcher("wdio.conf.js", {port: 9515});) and spawn the selenium and chromedriver processes yourself, and let the tests finsish, the processes disappear on their own. That means under normal circumstances Selenium handles the clean up itself without the need to kill processes. The problem seems to be rooted in the test runner: node_modules/webdriverio/build/lib/runner.js: process.exit() //case: 50 | line ~280 It probably exits the session too early. I assume the session process is the same that spawned the selenium server via the selenium service module? If so, when it exits it also kills the selenium (java) child process which, at this point, has not shutdown Chromedriver yet. But that is all a bit iffy though. Because the following workaround should actualy work: Spawn the Java/Selenium process in the selenium-standalone module with the "detached" option true (https://nodejs.org/api/child_process.html#child_process_options_detached). This would decouple the Java process from Node so that Node could exit, leaving the cleanup to Selenium. While this does get rid of the Chromedriver, now a Java process stays open. Does Selenium shut down the driver but not itself then? But it does when running it programmatically! The only working solution is if you put the process.exit() in runner.js in a (long enough, +100ms) setTimeout. But that is kind of hacky. |
Bump. The suggested workaround does not work for new webdriverio v5, cause browser.end() does not exist anymore. Any ideas how to kill running chromedriver after test? @christian-bromann ? Edit: leaving |
For me, on mac and on v5, I added a call to delete session in the "after" hook and it resolved the cleanup issues.
|
On linux I had to edit this hooks: /**
* Gets executed after all tests are done. You still have access to all global variables from
* the test.
* @param {Number} result 0 - test pass, 1 - test fail
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that ran
*/
after: function(result, capabilities, specs) {
browser.pause(1000);
},
/**
* Gets executed right after terminating the webdriver session.
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param {Array.<String>} specs List of spec file paths that ran
*/
afterSession: function(config, capabilities, specs) {
browser.pause(1000);
}, |
clearing the object helped in my case |
workaround :
|
For versions 0.0.8 and 0.0.9, the test run does not shut down all 2.31-x64-chromedriver processes when finished. This does not happen when using firefox/geckodriver. When running more than one spec, multiple 2.31-x64-chromedriver processes get started but one will always remain per test run. I have tested this with 1 and 2 specs in the wdio conf.
Current workaround that works for me:
Add this to your wdio.config.js file.
The text was updated successfully, but these errors were encountered: