fix: give the playwright npm server time to shut down browser children#211
Open
jordanmiguel wants to merge 1 commit intopestphp:4.xfrom
Open
fix: give the playwright npm server time to shut down browser children#211jordanmiguel wants to merge 1 commit intopestphp:4.xfrom
jordanmiguel wants to merge 1 commit intopestphp:4.xfrom
Conversation
…wser 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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
When running a suite with
--headed, thepestprocess hangs indefinitely after the "Tests: N passed" summary prints. On CI / in shells with a pipe it keeps the shell prompt busy; locally the user has to hit Ctrl-C to reclaim the terminal.Repro (macOS + Linux, any project with browser tests):
./vendor/bin/pest tests/Browser --headed # Summary prints, then hangs.Headless mode is unaffected.
Root cause
In
PlaywrightNpmServer::stop():Symfony's
Process::stop($timeout)sendsSIGTERM, waits$timeoutseconds, then escalates toSIGKILL. 100ms is too short for headed Chromium — its graceful close typically takes 700–1200ms because it has to flush IPC to its GPU/renderer children, persist session state, and tear down its windows.With the old 100ms grace period the server receives
SIGKILLwhile Chromium is still in mid-shutdown; its stdin/stdout pipes stay open on orphan descriptors, so the parent PHP process blocks inproc_close/fclosewaiting on them. That is the observable hang.Fix
Bump the grace period to
2.0seconds. Plenty of headroom for headed Chromium on every platform tested (macOS 14 Apple Silicon, Ubuntu 22.04 x86_64) and still bounded so a truly stuck Playwright server still getsSIGKILL.Headless runs complete faster than the grace period, so there is no perceptible overhead —
stop()returns as soon as Node exits.Before / after
Notes
SIGKILLstill fires at T+2s — no regression vs. the current escalate-to-SIGKILL behaviour, just pushed out 1.9s.tests/CoreFeatures/HeadedShutdownTest.phpthat launches + closes + asserts the parent exits within N seconds) if that fits the project's testing philosophy.