Add resetBudget() to LeakyBucketRateLimit#369
Merged
Conversation
Adds a public method to fully reset the retry budget (zero consumed budget and stop any active restore interval). This is needed by river-manager to reset the budget when a client transitions from background to foreground — previous failures during OS backgrounding shouldn't count against the fresh reconnection attempt.
jackyzha0
approved these changes
Apr 7, 2026
jackyzha0
left a comment
Member
There was a problem hiding this comment.
lgtm this was explicit when we first started to avoid allowing retry spam on reload but i think time has shown us this is too aggressive
lets roll this out and watch the sessions per client metric
darshkpatel
added a commit
that referenced
this pull request
Apr 7, 2026
## Summary - Bumps version to 0.216.0 (includes `resetBudget()` from #369) - Adds test for `resetBudget`: verifies it zeroes consumed budget, resets backoff to 0, and stops the restore interval ## Test plan - All rate limit tests pass (9/9) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
resetBudget()public method toLeakyBucketRateLimitthat zeros out consumed budget and stops any active restore intervalriver-managerto reset retry budget when a client transitions from background → foregroundWhy
When mobile users background the app, the OS kills WebSocket connections (close code 1006). The retry budget accumulates failures during this time. When the user returns, the budget is already exhausted, causing all River services to immediately go fatal and show the "Please Refresh" modal — even though the network is fine.
With
resetBudget(),river-managercan give the client a fresh budget on foreground, allowing reconnection to be retried.