Repository navigation
Conversation
1 task done
The test simulated ECONNRESET, slept 500 ms, and expected the connection state to be .failed. That is the state the mock sets itself, so the test did not check anything the transport did. It was also flaky: the transport cancels the connection before reconnecting, after backoffDelay(for: 1), which is also 500 ms, changing the state to .cancelled. When the cancel won the race, the test failed. The test now waits, with a timeout, for the transport to cancel the connection, then checks that it stops sending heartbeats.
akhilcb
force-pushed
the
oss/heartbeat-test-disable-reconnect
branch
from
October 24, 2026 23:13
a750556 to
a3b7a76
Compare
varun06
approved these changes
Oct 25, 2026
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.
Motivation and Context
Heartbeat Failure HandlinginNetworkTransportTestsis flaky and fails CI intermittently(
Expected state to be failed). The test simulatesECONNRESET, sleeps 500 ms, and expectsthe connection state to be
.failed. That is the state the mock sets itself, so the testdoes not check anything the transport did.
After a receive error, the transport marks itself disconnected and, after
backoffDelay(for: 1)(also 500 ms), cancels the connection and tries to reconnect. Thatcancel changes the state to
.cancelled; when it wins the race against the test's sleep,the test fails.
The test now checks what the transport does after the failure:
on a fixed sleep;
Reconnection stays at its default. Disabling it would leave the test checking only the
mock's own state, and the test would fail once #283 cancels the connection when
reconnection is disabled.
How Has This Been Tested?
swift testpasses; ran the full suite three times in a row, and the test alone 10 times,with no failures.
.failed) or keepssending heartbeats after the connection is lost.
Breaking Changes
None. Test-only change.
Types of changes