diff --git a/src/node/BrowserRunner.ts b/src/node/BrowserRunner.ts index 2f62068c4b104..e2cc686add6a2 100644 --- a/src/node/BrowserRunner.ts +++ b/src/node/BrowserRunner.ts @@ -195,7 +195,7 @@ export class BrowserRunner { 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. + // processes of `this.proc` until the main Node.js process dies. proc.kill(); } }); @@ -203,7 +203,15 @@ export class BrowserRunner { // 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. 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) { throw new Error(