Repository navigation
Backport: harden TcpSpec abort/connection-fails + EventFilterTestBase races (#7815, #7870, #7797) - #8302
Merged
Aaronontheweb merged 4 commits intoJul 2, 2026
Conversation
…net#7815) The test 'Outgoing_TCP_stream_must_shut_down_both_streams_when_connection_is_aborted_remotely' was failing intermittently on Linux due to platform-specific TCP behavior. Root cause: - Linux requires active recv() calls to detect TCP RST during connection establishment - Test was creating "zombie" connections (established but not actively reading) - When abort happened before active reading, RST detection failed on Linux - Windows worked fine due to more aggressive RST detection Solution: 1. Wait for TCP connection to be fully established using ViaMaterialized 2. Start active reading with readSub.Request(1) to trigger recv() on Linux 3. Then abort - ensuring RST detection works reliably across platforms This makes the test behave like real applications that immediately start using their TCP connections, which is why real apps don't have this issue. Fixes the race condition that caused 11 failed attempts in PR akkadotnet#7813. (cherry picked from commit 6aee8bd)
Replace DNS hostname with direct IP address to eliminate non-deterministic
DNS resolution timing. The test was experiencing flaky failures because
DNS resolution for example.com could take 2+ seconds, leaving insufficient
time for the connection timeout to fire before the test timeout.
Changed from DnsEndPoint("example.com", 666) to IPEndPoint(192.0.2.1, 666)
using TEST-NET-1 reserved address. This ensures the connection attempt
starts immediately without DNS delays, allowing the connection timeout to
fire reliably within the 1-second window.
(cherry picked from commit 8c09452)
…rtial) Retry logger initialization with AwaitAssertAsync until the ForwardAllEventsTestEventListener acknowledges with "OK", instead of a single blocking SendRawLogEventMessage/ExpectMsg that can run before the logger has finished subscribing. Hand-authored partial backport of akkadotnet#7797: only the EventFilterTestBase portion is ported here, keeping v1.5's xUnit-3 `async ValueTask InitializeAsync` signature. The original akkadotnet#7797 also rewrote the TcpSpec `...terminates_unexpectedly` test (intentionally excluded — that fix was backported separately via akkadotnet#8301) and applied cosmetic collection-literal changes to two other TcpSpec methods (no behavior change, skipped). Also satisfies the repo guidance to prefer async TestKit methods (sync ExpectMsg -> await ExpectMsgAsync).
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.
Summary
Test-only backport to
v1.5of three flaky-test fixes fromdev. Three individual commits, one per source PR. No production code is touched.6aee8bd70, cherry-pick-x)Outgoing_TCP_stream_must_shut_down_both_streams_when_connection_is_aborted_remotely(TcpSpec)ViaMaterialized(..., Keep.Right)+await connectionTask) and starts active reading (readSub.Request(1)) before the remoteAbort(), so Linux epoll actually issues therecv()that detects the TCP RST. Switches the assertion toExpectErrorAsync().8c094522c, cherry-pick-x)Outgoing_TCP_stream_must_fail_the_materialized_task_when_the_connection_fails(TcpSpec)new DnsEndPoint("example.com", 666)withnew IPEndPoint(IPAddress.Parse("192.0.2.1"), 666)(TEST-NET-1, non-routable) so the connection attempt starts immediately instead of waiting on DNS resolution.EventFilterTestBase(Akka.TestKit.Tests)AwaitAssertAsyncuntil theForwardAllEventsTestEventListeneracknowledges with"OK", instead of a single blockingSendRawLogEventMessage/ExpectMsgthat can run before the logger has finished subscribing.Notes / honest caveats
TcpSpec.Outgoing_TCP_stream_must_shut_down_both_streams_when_connection_is_aborted_remotelyrace condition on Linux #7815 is a real Linux-epoll RST race fix (not just a timing tweak): without the activerecv()before the abort, Linux never detects the RST on a "zombie" (established-but-not-reading) connection, whereas Windows detects it more aggressively.connectionTimeoutvs. the 3 s test timeout) by removing the variable-latency DNS lookup so the connect timeout can fire well inside the window.EventFilterTestBaselogger-subscription retry is included.async ValueTask InitializeAsyncsignature (dev's version reintroduced xUnit-2Task/TestKit.Xunit2signatures, which do not apply on v1.5)....terminates_unexpectedlyTcpSpecrewrite is intentionally excluded — that fix was backported separately and better via Backport: harden TcpSpec.Outgoing_TCP_stream_must_handle_when_connection_actor_terminates_unexpectedly (backport of #7827) #8301.TcpSpechunks were cosmetic collection-literal ([...]) changes with no behavior change — skipped.ExpectMsg->await ExpectMsgAsync).This PR is standalone and separate from the other v1.5 flaky-test backports (#8296 / #8298 / #8300 / #8301).
Local validation (Linux,
net10.0)dotnet build Akka.Streams.Tests -c Release -warnaserror --framework net10.0-> 0 warnings, 0 errorsdotnet build Akka.TestKit.Tests -c Release -warnaserror --framework net10.0-> 0 warnings, 0 errors~shut_down_both_streams_when_connection_is_aborted) -> 5/5 pass~fail_the_materialized_task_when_the_connection_fails) -> passEventFilterTestBase-derived specs (~EventFilter, 220 tests) x5 -> 5/5 pass (220/220 each)