diff --git a/src/node/BrowserRunner.ts b/src/node/BrowserRunner.ts index f2dc6075857e7..7b3942cf011c1 100644 --- a/src/node/BrowserRunner.ts +++ b/src/node/BrowserRunner.ts @@ -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. diff --git a/test/headful.spec.ts b/test/headful.spec.ts index 1085265a7ce50..b41eabc8ea934 100644 --- a/test/headful.spec.ts +++ b/test/headful.spec.ts @@ -143,7 +143,6 @@ describeChromeOnly('headful tests', function () { const devtoolsPageTarget = await browser.waitForTarget( (target) => target.type() === 'other' ); - console.log(devtoolsPageTarget); const page = await devtoolsPageTarget.page(); expect(await page.evaluate(() => 2 * 3)).toBe(6); await browser.close();