Skip to content

fix: stop waiting when the Playwright connection closes - #282

Open
yeapea wants to merge 1 commit into
pestphp:5.xfrom
yeapea:fix/an-unreadable-frame-ends-the-wait
Open

yeapea wants to merge 1 commit into
pestphp:5.xfrom
yeapea:fix/an-unreadable-frame-ends-the-wait

Conversation

@yeapea

@yeapea yeapea commented Oct 6, 2026

Copy link
Copy Markdown

When the Playwright server's websocket closes, receive() returns null, fetch() turns that into an empty string, and json_decode('') gives null. None of the checks in execute() can match null, so the loop never ends and the run just sits there until some outer timeout kills it.

This throws a ServerNotFoundException when a frame doesn't decode to an array, so the test fails with a message instead of hanging.

I added a unit test that sets a mocked connection whose receive() returns null. Without the change it never finishes (I had to kill it after 20 seconds). With it, it passes in well under a second. Locally I only ran that test and PHPStan on src, not the full suite.

Happy to use a different exception if you'd rather keep ServerNotFoundException for the HTTP server.

When the websocket closes, receive() returns null, so fetch() hands
back an empty string and json_decode() turns that into null. Neither
the error branch nor the break condition can match null, so execute()
keeps looping until something outside the test kills it.

Throw a ServerNotFoundException instead, and add a unit test that gives
the client a connection whose receive() returns null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant