Created
December 1, 2025 16:22
-
-
Save badsyntax/f6c7e03c0f4f30874bafe5b6473fed22 to your computer and use it in GitHub Desktop.
playwright not ending tests
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment