Skip to content

Commit bfa15aa

Browse files
author
User
committed
Fix flaky test_one_websocket_per_page after the offline test
`test_offline_component` tears down the offline webserver while the shared Playwright page is still on the /offline/ page. That page's client (`createReconnectingWebSocket`) keeps retrying the now-dead port on a backoff timer, so a reconnect attempt that lands inside the next test's navigation window leaks a second WebSocket URL and flakes `test_one_websocket_per_page` (observed intermittently on CI as "Expected 1 unique WebSocket URL, got 2 ... /offline/"). Navigating to about:blank at the end of `test_offline_component` destroys the document and cancels its pending reconnect timers, so later tests start from a clean state.
1 parent 43527ef commit bfa15aa

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎tests/test_app/tests/test_components.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,18 @@ def test_offline_component(self):
711711
self.page.wait_for_selector("div:not([hidden]) > #offline")
712712
assert self.page.query_selector("div[hidden] > #online") is not None
713713

714+
# Tearing down the server above severs the offline page's WebSocket, but its
715+
# client (createReconnectingWebSocket) keeps retrying the now-dead port on a
716+
# backoff timer for the rest of the session. All tests share one browser page,
717+
# so that zombie loop keeps firing `new WebSocket()` against the dead port
718+
# during subsequent tests. Any attempt that lands inside another test's
719+
# navigation window leaks a second WebSocket URL and flakes tests such as
720+
# `test_one_websocket_per_page` (observed intermittently on CI as
721+
# "Expected 1 unique WebSocket URL, got 2 ... /offline/"). Navigating away
722+
# destroys this document and cancels its pending reconnect timers, so later
723+
# tests start from a clean state with no lingering client.
724+
self.page.goto("about:blank")
725+
714726
##############
715727
# Form Tests #
716728
##############

0 commit comments

Comments
 (0)