Fix launcher to not leak event listeners (#605)

This patch fixes launcher to not leak event listeners.
This commit is contained in:
Andrey Lushnikov 2017-08-29 22:49:50 -07:00 committed by GitHub
parent 11ce8b249f
commit c9b0a6c060

View File

@ -85,13 +85,12 @@ class Launcher {
}
// Cleanup as processes exit.
let killed = false;
process.once('exit', killChrome);
if (temporaryUserDataDir)
chromeProcess.once('close', () => removeSync(temporaryUserDataDir));
const listeners = [ helper.addEventListener(process, 'exit', killChrome) ];
if (options.handleSIGINT !== false)
process.once('SIGINT', killChrome);
listeners.push(helper.addEventListener(process, 'SIGINT', killChrome));
try {
const connectionDelay = options.slowMo || 0;
@ -104,9 +103,7 @@ class Launcher {
}
function killChrome() {
if (killed)
return;
killed = true;
helper.removeEventListeners(listeners);
if (process.platform === 'win32')
childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`);
else