fix(Launcher): exit the process after killing chrome on SIGINT (#2428)

This is a fix for this issue https://github.com/facebook/jest/issues/5748

In the issue, `puppeteer.launch` method is called from jest `globalSetup` script which [is running on the same process as jest](6a77ee37ec/packages/jest-cli/src/run_jest.js (L242)).

Puppeteer catches `SIGINT` in order to kill chrome, but it also replaces the default behaviour of `SIGINT`, [which is to exit with status code 130](https://nodejs.org/dist/latest-v9.x/docs/api/all.html#process_signal_events). In jest's case, the process does not exit, which keeps the process hanging in a weird way.

This PR makes sure that the process exits after killing chrome.
This commit is contained in:
Ran Yitzhaki 2018-04-26 01:29:14 +03:00 committed by Andrey Lushnikov
parent 84d7b4963e
commit 8fce3195d6

View File

@ -143,7 +143,7 @@ class Launcher {
const listeners = [ helper.addEventListener(process, 'exit', killChrome) ];
if (options.handleSIGINT !== false)
listeners.push(helper.addEventListener(process, 'SIGINT', killChrome));
listeners.push(helper.addEventListener(process, 'SIGINT', () => { killChrome(); process.exit(130); }));
if (options.handleSIGTERM !== false)
listeners.push(helper.addEventListener(process, 'SIGTERM', gracefullyCloseChrome));
if (options.handleSIGHUP !== false)