-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unreliable process killing on windows #266
Comments
chrome-launcher kills like this: chrome-launcher/src/chrome-launcher.ts Lines 375 to 403 in 279577f
pptr kills like this: in fact the playwright kills like this: playwright had another fix for both pptr and playwright use the |
I charted out playwrights complete flow in pseudo cuz i was pretty curious. it's interesting, though i'm not sure how deliberate it is at this point: async function closeOrKill() {
try {
await Promise.race([gracefullyClose(), deadlinePromise]);
} catch (e) {
await killProcessAndCleanup().catch(_ => {});
}
}
spawnedProcess.once('exit', (exitCode, signal) => {
removeEventListeners();
cleanupTmpDir();
});
process.on('exit', killProcessAndCleanup);
onSigInt(async _ => {
await gracefullyClose();
process.exit(130);
});
async function gracefullyClose() {
if (alreadyGracefullyClosing) {
await killProcess();
await cleanupTmpDir();
return;
}
await cdp.send('Browser.close').catch(_ => killProcess());
await cleanupTmpDir();
}
function killProcess() {
removeEventListeners();
if (process.pid & !killed && !closed) {
try {
if (win32) {
spawnSync('taskkill /t /f ... ');
} else {
process.kill(-pid, 'sigkill');
}
} catch (e) {
log('process already done');
}
} else {
log('already done i guess');
}
}
function killProcessAndCleanup() {
killProcess();
cleanupTmpDir();
}
function cleanupTmpDir() {
rimraf(userdatadir);
} |
Last things worth comparing: should chrome process be launched as detached?
do you resolve or reject if the
|
Another example in GoogleChrome/lighthouse#14376 |
There are several issues about this problem. (in this repo and in ligththouse's)
I'm going to jot down some notes here.
We use
taskkill
to kill the chrome process on windows:chrome-launcher/src/chrome-launcher.ts
Line 388 in 279577f
We have intermittent failures where this command fails and thus
launcher.kill()
rejects. The failures look like:History of related changes:
taskkill
cmd is piped up but not emitted.The text was updated successfully, but these errors were encountered: