fix(watcher): apply backoff when sync stream ends without error#82
Merged
Conversation
When the server closed the Subscribe stream normally, the outer reconnect loop re-issued Subscribe immediately with no delay, causing a tight reconnect loop on a server FIN. Port the same backoff branch that already exists in async_watcher.py: after a clean stream close, sleep for backoff * jitter seconds (in 0.1s intervals so stop_event is honoured) and grow backoff the same way error reconnects do. Closes #51 Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude <noreply@anthropic.com>
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
ConfigWatcherreconnected immediately after a clean server-side stream close, causing a tight reconnect loop on a server FIN.async_watcher.py— on a normal stream close, the watcher now sleepsbackoff × jitterseconds (in 0.1 s intervals so the stop event is honoured) and grows the backoff the same way error reconnects do.Test plan
test_reconnects_after_clean_stream_close— verifies Subscribe is called at least twice after a clean closetest_clean_close_applies_backoff— measures the wall-clock gap between calls and asserts it exceeds the minimum jitter floorCloses #51
🤖 Generated with Claude Code