Version
main branch as of 2026-06-09
Steps to reproduce
- Start a remote browser server.
- Connect with
browser_type.connect(...).
- Start a pending waiter, for example
page.wait_for_event("download").
- Close the remote browser or stop the remote server.
This is already called out in the Python source with a TODO that points to the upstream Playwright fix: microsoft/playwright@d8d5289
Expected behavior
Pending page/context API waiters should reject before browser.close() returns or before the browser disconnected event is emitted.
Actual behavior
Python still has the old remote-close ordering path in playwright/_impl/_browser_type.py. It closes page/context/browser objects synchronously and only then cleans up the connection.
Additional context
This is a small backport/parity fix. The upstream tests are:
- should reject
waitForEvent before browser.close finishes
- should reject
waitForEvent before browser.onDisconnect fires
Potential fix direction
Port the upstream ordering change to Python: clean up/reject the remote connection first, then schedule page/context/browser close notifications on the next event-loop turn. Add focused async tests for both close and remote-server-disconnect paths.
Version
main branch as of 2026-06-09
Steps to reproduce
browser_type.connect(...).page.wait_for_event("download").This is already called out in the Python source with a TODO that points to the upstream Playwright fix: microsoft/playwright@d8d5289
Expected behavior
Pending page/context API waiters should reject before
browser.close()returns or before the browserdisconnectedevent is emitted.Actual behavior
Python still has the old remote-close ordering path in
playwright/_impl/_browser_type.py. It closes page/context/browser objects synchronously and only then cleans up the connection.Additional context
This is a small backport/parity fix. The upstream tests are:
waitForEventbeforebrowser.closefinisheswaitForEventbeforebrowser.onDisconnectfiresPotential fix direction
Port the upstream ordering change to Python: clean up/reject the remote connection first, then schedule page/context/browser close notifications on the next event-loop turn. Add focused async tests for both close and remote-server-disconnect paths.