Skip to content

Comments

Fix off-by-one error in reconnection attempts#1356

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-off-by-one-error
Open

Fix off-by-one error in reconnection attempts#1356
Copilot wants to merge 4 commits intomainfrom
copilot/fix-off-by-one-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

  • Investigate off-by-one error in SendGetSseRequestWithRetriesAsync retry loop
  • Fix: initialize attempt = -1 when state.LastEventId is null (initial connection case in ReceiveUnsolicitedMessagesAsync)
  • Build and test (all tests pass; pre-existing auth conformance failures on net8.0 are unrelated)
  • Add unit test verifying the initial GET SSE connection doesn't consume a reconnection slot
  • Fix net472 build: use TaskCompletionSource<bool> instead of non-generic TaskCompletionSource
  • Code review (no issues found)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Feb 22, 2026
…n loop

When ReceiveUnsolicitedMessagesAsync calls SendGetSseRequestWithRetriesAsync,
the first attempt is an initial GET SSE connection (not a reconnection).
Previously, this initial attempt was counted against MaxReconnectionAttempts,
meaning with the default value of 2, only 1 actual reconnection was made.

Fix: initialize attempt = -1 when LastEventId is null (initial connection),
so the initial attempt doesn't consume a reconnection slot. When LastEventId
is set (pure reconnection from POST SSE resume), attempt starts at 0 as before.

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
@stephentoub stephentoub added this to the 1.0.0 (GA) milestone Feb 22, 2026
…axReconnectionAttempts

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot AI requested a review from stephentoub February 22, 2026 02:51
@stephentoub stephentoub changed the title [WIP] Fix off-by-one error in reconnection attempts Fix off-by-one error in reconnection attempts Feb 22, 2026
@stephentoub stephentoub marked this pull request as ready for review February 22, 2026 03:44
@stephentoub stephentoub requested a review from halter73 February 22, 2026 03:44
@stephentoub
Copy link
Contributor

@copilot there are build failures

…ic TaskCompletionSource

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 22, 2026

@copilot there are build failures

Fixed in 1f850f0. The non-generic TaskCompletionSource isn't available on net472 — changed to TaskCompletionSource<bool> to match the pattern used elsewhere in the test project.

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.

2 participants