Skip to content

Commit

Permalink
fix: kill browser process when 'taskkill' fails on Windows (#8352)
Browse files Browse the repository at this point in the history
  • Loading branch information
szuend committed May 16, 2022
1 parent 24dfbd5 commit dccfadb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/node/BrowserRunner.ts
Expand Up @@ -186,7 +186,14 @@ export class BrowserRunner {
if (this.proc && this.proc.pid && pidExists(this.proc.pid)) {
try {
if (process.platform === 'win32') {
childProcess.exec(`taskkill /pid ${this.proc.pid} /T /F`, () => {});
childProcess.exec(`taskkill /pid ${this.proc.pid} /T /F`, (error) => {
if (error) {
// 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
// proccesses of `this.proc` until the main Node.js process dies.
this.proc.kill();
}
});
} else {
// 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.
Expand Down

0 comments on commit dccfadb

Please sign in to comment.