diff --git a/tests/config/remoteServer.ts b/tests/config/remoteServer.ts index b541628da09c7..75758833da47e 100644 --- a/tests/config/remoteServer.ts +++ b/tests/config/remoteServer.ts @@ -165,7 +165,17 @@ export class RemoteServer implements PlaywrightServer { await this._browser.close(); this._browser = undefined; } - await this._process.kill('SIGINT'); - await this.childExitCode(); + // The launchServer child forwards SIGINT to gracefully close the browser and + // then exit. A headed browser can intermittently fail to terminate on SIGINT + // (observed on macOS chromium), which leaves the child alive and hangs + // teardown until the test timeout. Give graceful shutdown a chance, then + // escalate to SIGKILL so teardown stays bounded. + void this._process.kill('SIGINT'); + const killTimer = setTimeout(() => void this._process.kill('SIGKILL'), 10000); + try { + await this.childExitCode(); + } finally { + clearTimeout(killTimer); + } } }