mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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.
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user