Repository navigation
test: deflake the background socket test - #57
Merged
Merged
Conversation
ws.gleap.test does not resolve, so the socket the helper opens on returning to the foreground fails a few milliseconds later (the lookup is cached after the first one) and is cleared right away. The test polled webSocketTask every 20 ms and missed that window now and then. It now records every socket the helper opens (KVO on webSocketTask), pins the online flag and waits up to 10 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
GleapWebSocketTests.testNoSocketOpensInTheBackgroundUntilTheAppReturnsfailed on main after the 19.2.3 and 19.2.4 merges.Cause. The test hostname
ws.gleap.testdoes not resolve. After the first lookup the failure is cached, so a socket fails about 2–3 ms after it opens. The helper then clearswebSocketTaskinreconnectAfterFailure. The test checkedwebSocketTaskevery 20 ms (onewaitUntilrun-loop slice), so it only passed when a check happened to land inside that window. It had two chances in 5 s: the connect 1.5 s after the foreground notification, and the first retry 1.6–2.4 s later. Reproduced locally: 1 of 8 repetitions failed with "did not connect after returning to the foreground".Fix (test only). The test now records every socket the helper opens by observing
webSocketTaskwith KVO, so a short-lived socket still counts. It also pins the internalonlineflag to true (via KVC) so the path monitor's state can't affect the test, and it waits up to 10 s. The background assertion is also stricter now: no socket for the channel may open at all in the background, not just be open at the moment of the check.There is no production change: the helper connects 1.5 s after returning to the foreground, as designed.
Verification.
GleapWebSocketTestspassed 20/20 with-test-iterations 20(it had failed 1/8 before the fix), and.github/scripts/test.shwas run 5× on the full suite.🤖 Generated with Claude Code