fix: Kill browser process when killing process group fails (#8477)

Fixes #8476. Similar fix to #8352 which only covered Windows.
This commit is contained in:
James Diefenderfer 2022-06-07 06:25:45 -07:00 committed by GitHub
parent b54dc55f76
commit 7dc8e37a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,7 +195,7 @@ export class BrowserRunner {
if (error) { if (error) {
// taskkill can fail to kill the process e.g. due to missing permissions. // taskkill can fail to kill the process e.g. due to missing permissions.
// Let's kill the process via Node API. This delays killing of all child // Let's kill the process via Node API. This delays killing of all child
// proccesses of `this.proc` until the main Node.js process dies. // processes of `this.proc` until the main Node.js process dies.
proc.kill(); proc.kill();
} }
}); });
@ -203,7 +203,15 @@ export class BrowserRunner {
// on linux the process group can be killed with the group id prefixed with // on linux the process group can be killed with the group id prefixed with
// a minus sign. The process group id is the group leader's pid. // a minus sign. The process group id is the group leader's pid.
const processGroupId = -this.proc.pid; const processGroupId = -this.proc.pid;
process.kill(processGroupId, 'SIGKILL');
try {
process.kill(processGroupId, 'SIGKILL');
} catch (error) {
// Killing the process group can fail due e.g. to missing permissions.
// Let's kill the process via Node API. This delays killing of all child
// processes of `this.proc` until the main Node.js process dies.
proc.kill('SIGKILL');
}
} }
} catch (error) { } catch (error) {
throw new Error( throw new Error(