From 8fce3195d6289313f7ed201f3efeaa1cfebf17ec Mon Sep 17 00:00:00 2001 From: Ran Yitzhaki Date: Thu, 26 Apr 2018 01:29:14 +0300 Subject: [PATCH] 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](https://github.com/facebook/jest/blob/6a77ee37ec2d46ece7e9cfd0f891d11c113cc4c4/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. --- lib/Launcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Launcher.js b/lib/Launcher.js index fa0cb97f..a1be6029 100644 --- a/lib/Launcher.js +++ b/lib/Launcher.js @@ -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)