webdriverio-boneyard / gulp-webdriver

gulp-webdriver is a gulp plugin to run selenium tests with the WebdriverIO testrunner
http://webdriver.io
MIT License
76 stars 33 forks source link

SIGINT handler is not killing process #56

Open christian-bromann opened 7 years ago

christian-bromann commented 7 years ago

From @artur-michalak on January 4, 2017 12:5

The problem

When i setup webdriver.io with gulp watch and interrupt process with ctrl+c it's not closing.

Environment

Link to Selenium/WebdriverIO logs

[12:56:45] Finished 'e2e:run' after 16 s [12:56:45] Finished 'e2e:dev' after 17 s then on cmd + c click:

End selenium sessions properly ... (press crtl+c again to hard kill the runner)

Killing process, bye! (on cmd + c click) Killing process, bye! (on cmd + c click) Killing process, bye! (on cmd + c click) Killing process, bye! (on cmd + c click)

Code To Reproduce Issue [ Good To Have ]

  1. Setup gulp gulp.task('e2e:run', function () { return gulp.src(config.e2e.config).pipe(webdriver({ baseUrl: 'http://localhost:' + config.e2e.port, specs: config.e2e.specs })).on('error', handleErrors); });

// production release of player gulp.task('e2e:dev', function() { gulp.watch(config.e2e.specs, ['e2e:run']); });

  1. Run e2e:run task. Everything works like a charm
  2. Run e2e:dev which is watching files
  3. Interrupt (ctrl + c/cmd+c) twice
  4. Gulp process is not killed

Details

I would guess something is wrong with logic here https://github.com/webdriverio/webdriverio/blob/68974ac33aa13fa099b1870d5a81ce5c6d8341db/lib/launcher.js#L418 Perhaps process.exit is not being called.

Copied from original issue: webdriverio/webdriverio#1798

sandys commented 7 years ago

i have the exact same issue. i have a feeling this is because of gulp which is not passing on signals correctly.

gpolyn commented 7 years ago

What is the status of this issue?

jsdtaylor commented 6 years ago

Not sure why this got moved from webdriverio as grunt-webdriver exhibits it as well. Any news?

christian-bromann commented 6 years ago

I am not using gulp-webdriver so if anyone has a solution to this any PRs would be appreciated

stsvilik commented 6 years ago

There is one solution that I found to be working - its not ideal but it is something. Returned through2 stream has an event finish which you could use to exit the process. Ex.

webdriver({
    baseUrl: 'http://localhost:' + config.e2e.port,
    specs: config.e2e.specs
}).on(`finish`, () => process.exit(0));
jasp402 commented 6 years ago

@stsvilik effectively closing the process, the only bad thing is that it eliminates all the underlying sub-processes. I have built a nodeJS server and when applying this solution it stops the service.

There should be some way to get PID and stop just that process. Maybe you can use process.kill (pid [, signal])

stsvilik commented 6 years ago

@jasp402 If only we had reference to the right process which spawns webdriver, we could kill just that.