From 03acec9859c3cdf60d66cb67f2d6cb70dba6321b Mon Sep 17 00:00:00 2001 From: Jordan Miguel Date: Thu, 23 Apr 2026 01:23:49 -0300 Subject: [PATCH] fix(playwright): give the playwright npm server time to shut down browser children Symfony's Process::stop(0.1) sent SIGTERM and escalated to SIGKILL after 100ms. In headed mode, Chromium's graceful close typically needs ~1s; the SIGKILL interrupted mid-teardown, leaving orphan browser processes and stalled pipes. The parent pest process then hung on wait() for file handles that never closed, forcing the user to Ctrl-C. Bumps the grace period to 2.0s, which consistently clears Chromium even in headed mode on macOS/Linux. Headless mode was unaffected; headed-mode runs now exit cleanly. --- src/Playwright/Servers/PlaywrightNpmServer.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Playwright/Servers/PlaywrightNpmServer.php b/src/Playwright/Servers/PlaywrightNpmServer.php index 9d06f4a6..e6bbf033 100644 --- a/src/Playwright/Servers/PlaywrightNpmServer.php +++ b/src/Playwright/Servers/PlaywrightNpmServer.php @@ -94,8 +94,14 @@ public function start(): void public function stop(): void { if ($this->systemProcess instanceof SystemProcess && $this->isRunning()) { + // The Playwright node server needs time to clean up its browser + // children — especially Chromium in headed mode, which can take + // close to a second to shut down gracefully. With the old 0.1s + // timeout, SIGTERM raced the browser teardown and Symfony would + // escalate to SIGKILL while children were still detaching, + // leaving the parent pest process waiting on zombie file handles. $this->systemProcess->stop( - timeout: 0.1, + timeout: 2.0, signal: PHP_OS_FAMILY === 'Windows' ? null : SIGTERM, ); }