Fix flaky test_one_websocket_per_page after the offline test - #301
Merged
Merged
Conversation
`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.
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.
Description
The periodic (nightly)
Test/python-sourcerun #35684228566 failed with:Root cause. The tests share a single browser page across the whole
ComponentTestsclass, and they run in alphabetical order — sotest_offline_componentruns immediately beforetest_one_websocket_per_page.test_offline_componentcallsself._server_process_1.terminate()while the page is still sitting on the/offline/page. Tearing down the server severs that page's WebSocket, but the page's client (createReconnectingWebSocketinsrc/js/src/websocket.ts) keeps retrying the now-dead port on a backoff timer for the rest of the session. Because the shared page is never navigated away, that zombie reconnect loop keeps firingnew WebSocket()against the dead port during subsequent tests.test_one_websocket_per_pageattaches a"websocket"listener and navigates to/. Any zombie reconnect attempt from the dead/offline/page that lands inside that navigation window is recorded, so the test sees two unique URLs (the home page and the leaked/offline/one) and fails. This is inherently probabilistic, which is why the identical commit passed on the previous nightly runs and only failed this one — exactly the signature of a flaky CI test.Fix. Navigate the shared page to
about:blankat the end oftest_offline_component. Leaving the document cancels its pending reconnect timers, so no zombie client is left to leak WebSocket connections into later tests. This is the same class of fix as the earlier timing-related flakiness addressed in #299 and keeps the fix entirely within the test harness (no product-code change).A minimal A/B reproduction (kill the offline server, then mimic
test_one_websocket_per_page) fails 8/8 without theabout:blanknavigation and passes 0/8 with it. The fullComponentTestsclass and the wholesingle_dbsuite pass locally after the change.Checklist
test_one_websocket_per_pageis the regression test, and it no longer flakes once the zombie reconnect is cleared.