Repository navigation
fix: stop the playwright server process, not only its shell - #281
Open
Leander-Forma wants to merge 1 commit into
Open
Leander-Forma wants to merge 1 commit into
Leander-Forma wants to merge 1 commit into
Conversation
The server is started with Process::fromShellCommandline(), so on Linux and macOS the tree is `sh -c "./node_modules/.bin/playwright run-server ..."` with node as a child of sh. stop() signals the sh, which exits, and node keeps running and listening, reparented to init. Every run leaves one server behind. Prefixing the command with `exec` makes node the process that is started and signalled. Windows runs the command through cmd and is left as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
PlaywrightNpmServer::start()prefixes the command withexec(not on Windows).Why
The server is started with
Process::fromShellCommandline(). On Linux and macOS that gives this tree:stop()signals thesh. Theshexits,nodeis reparented to init (orsystemd --user) and keeps listening. So every test run, also a clean one, leaves a Playwright server of ~170 MB behind. On a machine where several runs happen in a day they pile up. We found 28 of them on a shared dev VM in one morning.A side effect: a caller that pipes Pest's output (
vendor/bin/pest | tail) can hang after the run, because the leftover node still holds the pipe open.With
exec, the shell is replaced by node, so the process Symfony signals is the server itself.Test
tests/Unit/Playwright/PlaywrightNpmServerTest.phpstarts the server, stops it, and asserts that nothing listens on the port anymore. It fails on the current code ("Failed asserting that true is false") and passes with the change. Skipped on Windows.composer test:unit,phpstan,pint --testandrector --dry-runpass locally.🤖 Generated with Claude Code