Repository navigation
Conversation
The test called connect() from the test thread and attached the close callback afterwards. If the event loop completed the connection first, channelActive fired and the handler failed the test. This happens when the test thread is slow, for example under parallel test runs. Connect and attach the close callback inside eventLoop.flatSubmit so the callback is always attached before the connection can complete.
iwang-1
force-pushed
the
fix-flaky-directly-closed-test
branch
from
November 18, 2026 23:01
b73a7ea to
d6a6428
Compare
This branch has not been deployed
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.
Fix a race that makes
testNoActiveInactiveNotificationsWhenDirectlyClosedflaky.Motivation:
ChannelNotificationTest.testNoActiveInactiveNotificationsWhenDirectlyClosedfailed for me when running the full test suite withswift test --parallelon macOS (arm64):It passed every time when run on its own. The test calls
connect()from the test thread and only afterwards attaches theflatMapthat closes the channel. If the event loop completes the connection and fireschannelActivebefore the test thread attaches that callback, the handler seeschannelActiveand fails. That happens when the test thread is slow, for example when other tests run in parallel.Adding a 100 ms sleep on the test thread between
connect()andflatMapmade the test fail in 3 of 3 runs.Modifications:
eventLoop.flatSubmit, so the callback is attached before the event loop can complete the connection.Result:
The test no longer depends on thread timing. With the same 100 ms sleep added after
flatSubmit, it passed in 3 of 3 runs. The change only touches this test.🤖 Generated with Claude Code