Kill Chrome quickly on Windows (#488)
This patch start killing chrome on windows with taskkill command.
This commit is contained in:
parent
a00ba6a3d9
commit
ac109dba6d
@ -82,26 +82,31 @@ class Launcher {
|
||||
}
|
||||
|
||||
// Cleanup as processes exit.
|
||||
const listeners = [
|
||||
helper.addEventListener(process, 'exit', killChromeAndCleanup),
|
||||
helper.addEventListener(chromeProcess, 'exit', killChromeAndCleanup),
|
||||
];
|
||||
let killed = false;
|
||||
process.once('exit', killChrome);
|
||||
chromeProcess.once('close', () => removeSync(userDataDir));
|
||||
|
||||
if (options.handleSIGINT !== false)
|
||||
listeners.push(helper.addEventListener(process, 'SIGINT', killChromeAndCleanup));
|
||||
process.once('SIGINT', killChrome);
|
||||
|
||||
try {
|
||||
const connectionDelay = options.slowMo || 0;
|
||||
const browserWSEndpoint = await waitForWSEndpoint(chromeProcess, options.timeout || 30 * 1000);
|
||||
const connection = await Connection.create(browserWSEndpoint, connectionDelay);
|
||||
return new Browser(connection, !!options.ignoreHTTPSErrors, killChromeAndCleanup);
|
||||
return new Browser(connection, !!options.ignoreHTTPSErrors, killChrome);
|
||||
} catch (e) {
|
||||
killChromeAndCleanup();
|
||||
killChrome();
|
||||
throw e;
|
||||
}
|
||||
|
||||
function killChromeAndCleanup() {
|
||||
helper.removeEventListeners(listeners);
|
||||
chromeProcess.kill('SIGKILL');
|
||||
removeSync(userDataDir);
|
||||
function killChrome() {
|
||||
if (killed)
|
||||
return;
|
||||
killed = true;
|
||||
if (process.platform === 'win32')
|
||||
childProcess.execSync(`taskkill /pid ${chromeProcess.pid} /T /F`);
|
||||
else
|
||||
chromeProcess.kill('SIGKILL');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user