Fix launcher to not leak event listeners (#605)
This patch fixes launcher to not leak event listeners.
This commit is contained in:
parent
11ce8b249f
commit
c9b0a6c060
@ -85,13 +85,12 @@ class Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup as processes exit.
|
// Cleanup as processes exit.
|
||||||
let killed = false;
|
|
||||||
process.once('exit', killChrome);
|
|
||||||
if (temporaryUserDataDir)
|
if (temporaryUserDataDir)
|
||||||
chromeProcess.once('close', () => removeSync(temporaryUserDataDir));
|
chromeProcess.once('close', () => removeSync(temporaryUserDataDir));
|
||||||
|
|
||||||
|
const listeners = [ helper.addEventListener(process, 'exit', killChrome) ];
|
||||||
if (options.handleSIGINT !== false)
|
if (options.handleSIGINT !== false)
|
||||||
process.once('SIGINT', killChrome);
|
listeners.push(helper.addEventListener(process, 'SIGINT', killChrome));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const connectionDelay = options.slowMo || 0;
|
const connectionDelay = options.slowMo || 0;
|
||||||
@ -104,9 +103,7 @@ class Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function killChrome() {
|
function killChrome() {
|
||||||
if (killed)
|
helper.removeEventListeners(listeners);
|
||||||
return;
|
|
||||||
killed = true;
|
|
||||||
if (process.platform === 'win32')
|
if (process.platform === 'win32')
|
||||||
childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`);
|
childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user