Skip to content

Instantly share code, notes, and snippets.

@badsyntax
Created December 1, 2025 16:22
Show Gist options
  • Select an option

  • Save badsyntax/f6c7e03c0f4f30874bafe5b6473fed22 to your computer and use it in GitHub Desktop.

Select an option

Save badsyntax/f6c7e03c0f4f30874bafe5b6473fed22 to your computer and use it in GitHub Desktop.
playwright not ending tests
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