playwright.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/node_modules/playwright/lib/runner/processHost.js b/node_modules/playwright/lib/runner/processHost.js | |
| index a8ee4e7..8ce01c5 100644 | |
| --- a/node_modules/playwright/lib/runner/processHost.js | |
| +++ b/node_modules/playwright/lib/runner/processHost.js | |
| @@ -140,8 +140,20 @@ class ProcessHost extends import_events.EventEmitter { | |
| this.send({ method: "__stop__" }); | |
| this._didSendStop = true; | |
| } | |
| - if (!this._didExitAndRanOnExit) | |
| - await new Promise((f) => this.once("exit", f)); | |
| + if (!this._didExitAndRanOnExit) { | |
| + // Add timeout to force kill if process doesn't exit | |
| + const exitPromise = new Promise((f) => this.once("exit", f)); | |
| + const timeoutPromise = new Promise((resolve) => { | |
| + setTimeout(() => { | |
| + if (this.process && !this._processDidExit) { | |
| + console.log(`Force killing process ${this._processName} after 5s timeout`); | |
| + this.process.kill('SIGKILL'); | |
| + } | |
| + resolve(); | |
| + }, 5000); | |
| + }); | |
| + await Promise.race([exitPromise, timeoutPromise]); | |
| + } | |
| } | |
| didSendStop() { | |
| return this._didSendStop; |