Skip to content

Report a failed first connect once - #48

Merged
Agash merged 1 commit into
masterfrom
fix/connect-disconnect-race
Sep 23, 2026
Merged

Agash merged 1 commit into
masterfrom
fix/connect-disconnect-race

Conversation

@Agash

@Agash Agash commented Sep 23, 2026

Copy link
Copy Markdown
Owner

When the first connection attempt failed with auto-reconnect off, the connection loop and ConnectAsync both finalized the disconnect. Whichever ran first decided the reason Disconnected reported: either the loop's "failed to connect after 1 attempts" or the bare attempt failure. That made ConnectAsync_ConnectionFailedFirstAttempt_NoRetry_RaisesCorrectEvents flaky on the Linux runner, and it failed on master after #47.

ConnectAsync now waits for the loop when the loop is the one that gave up, so Disconnected fires once, with the loop's reason, before ConnectAsync throws. Timeouts and caller cancellation, where the loop may still be retrying, still stop it directly.

The new test holds the loop at the point it gives up, which makes the race deterministic. It failed on every run before this change.

@Agash
Agash merged commit 6404483 into master Sep 23, 2026
10 checks passed
@Agash
Agash deleted the fix/connect-disconnect-race branch September 23, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant