Skip to content

DS-4027: Reconnection Counter Underflow Fix - #73

Open
andrejrakic wants to merge 1 commit into
mainfrom
ds-4027/fix-reconnection-counter-underflow
Open

andrejrakic wants to merge 1 commit into
mainfrom
ds-4027/fix-reconnection-counter-underflow

Conversation

@andrejrakic

Copy link
Copy Markdown
Collaborator

Description

This PR fixes the Reconnection Counter Underflow issue and adds another unit test to confirm the fix.

What was the issue

Step Code path active_connections
Server sends Close frame Message::Close arm → fetch_sub(1) -1
Stream drains, yields None None arm → fetch_sub(1) -1 again ← bug
Reconnect succeeds try_to_reconnect → fetch_add(1) +1
Net per cycle   -1

Per WebSocket RFC 6455, after a Close frame the stream always yields None — the None arm is the definitive end-of-stream signal. The Message::Close arm should not decrement; removing that call makes each graceful close/reconnect cycle net-zero. Without the fix, repeated cycles underflow the AtomicUsize counter to usize::MAX, causing full reconnects to be misclassified as partial.

@andrejrakic
andrejrakic marked this pull request as ready for review September 11, 2026 11:21
@andrejrakic
andrejrakic requested a review from a team as a code owner September 11, 2026 11:21

This branch has not been deployed

No deployments
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