gulp-webdriver icon indicating copy to clipboard operation
gulp-webdriver copied to clipboard

SIGINT handler is not killing process

Open christian-bromann opened this issue 8 years ago • 7 comments

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

  • WebdriverIO version: v4.5.2

  • Node.js version: v4.4.5 (v6 too)

  • Standalone mode or wdio testrunner: jasmine testrunner

  • if wdio testrunner, running synchronous or asynchronous tests: asynchronous

  • Additional wdio packages used (if applicable):

    "wdio-dot-reporter": "0.0.6", "wdio-jasmine-framework": "^0.2.19", "wdio-selenium-standalone-service": "0.0.7", "gulp-webdriver": "^2.0.3",

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

christian-bromann avatar Jan 04 '17 12:01 christian-bromann

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

sandys avatar Feb 18 '17 10:02 sandys

What is the status of this issue?

gpolyn avatar Apr 04 '17 16:04 gpolyn

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

jsdtaylor avatar Nov 27 '17 10:11 jsdtaylor

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

christian-bromann avatar Nov 27 '17 11:11 christian-bromann

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));

stsvilik avatar Apr 13 '18 12:04 stsvilik

@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])

jasp402 avatar May 09 '18 15:05 jasp402

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

stsvilik avatar May 10 '18 15:05 stsvilik