Skip to content

fix: recover after a failed Playwright initialize - #275

Merged
MrPunyapal merged 8 commits into
pestphp:5.xfrom
tiagoabsantos:fix/failed-initialize-recovery
Oct 29, 2026
Merged

MrPunyapal merged 8 commits into
pestphp:5.xfrom
tiagoabsantos:fix/failed-initialize-recovery

Conversation

@tiagoabsantos

Copy link
Copy Markdown
Contributor

Summary

Fixes pestphp/pest#1938.

Playwright accepts initialize once per WebSocket and sets that flag before the browser launch finishes. If the launch hits the action timeout, $browserTypes stays empty, so the next browser test sends initialize again and every later test fails with Assertion error.

  • The one-time launch now uses a 30s timeout, separate from the action timeout.
  • A failed initialize closes the socket. The next browser test connects again and can initialize.

Test plan

  • tests/Browser/Visit/InitializeRecoveryTest.php forces a second initialize on the same connection, expects Assertion error, then opens a page on a new connection
  • Action timeout is unchanged after a successful launch and after the failed initialize
  • CI on PHP 8.4 and 8.5

Tiago Santos and others added 2 commits September 29, 2026 16:47
Playwright marks a connection initialized before the browser finishes launching, and it accepts that call only once. Give the launch its own timeout, and drop the socket when initialize fails so the next test can connect again.
@Victor-emil

Copy link
Copy Markdown

We hit this on GitHub Actions (ubuntu-latest, pest --parallel --testsuite=Browser, v5.0.1, with the same code on 5.x). Now and then, one worker's first browser test fails with Timeout 5000ms exceeded., and every following test in that worker then fails at its first step with Assertion error. In one run, over 70 tests failed this way.

We reproduced it locally by stopping the Chrome process that the Playwright server starts (kill -STOP) right after the first initialize was sent, and continuing it 8 s later. Without a fix, all 24 tests in the file failed. With initialize sent with a launch-sized timeout, all 24 passed, also with a 20 s pause. So a separate timeout for the launch, as in this PR, fixes it for us. Thanks for the PR!

@MrPunyapal
MrPunyapal merged commit 2b5c7b5 into pestphp:5.x Oct 29, 2026
2 checks passed
@MrPunyapal

Copy link
Copy Markdown
Member

Thanks

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.

[pest-plugin-browser] Timed-out initialize corrupts every later browser test

3 participants