Stabilize Postgres reconnect test against reconnect timing race - #9946
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR stabilizes the ResilientNpgsqlConnection Postgres reconnect test by removing a fixed-duration wait that can flake under CI load, and replacing it with a deterministic await tied to the actual reconnect event.
Changes:
- Replaced
SpinWait.SpinUntil(..., 1s)with aTaskCompletionSourcethat completes when the secondonConnectfires (reconnect), with a 10s ceiling. - Ensured the assertion runs only after the reconnect callback indicates the connection swap has occurred, matching the pattern used by the sibling reconnect test.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall coverage in the Show a code coverage summary of the most impacted files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
This was referenced Jun 22, 2026
This was referenced Jul 2, 2026
Open
This was referenced Jul 13, 2026
This was referenced Jul 20, 2026
chore(deps): Bump HotChocolate.Subscriptions.InMemory from 15.1.14 to 16.5.1
Kuestenlogik/Bowire#506
Merged
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
Reconnect_Should_ReconnectWhenConnectionIsClosedwaited a fixed 1 second (SpinWait.SpinUntil) for the background reconnect to swap in a new connection, then asserted unconditionally. Under CI load the reconnect can exceed that window, producing an intermittentAssert.NotEqualfailure.TaskCompletionSourcesignalled by the reconnect'sonConnectcallback (10s ceiling), mirroring the siblingReconnect_Should_CallOnDisconnect_When_ConnectionIsClosedtest.Connectionis assigned beforeonConnectis awaited, so the new connection is guaranteed to be in place when the assertion runs.Test plan
HotChocolate.Subscriptions.Postgres.Testsand ran the affected test 10× locally on net10.0: 10/10 passed.