Add fast-loop detection and backoff for proxy misconfiguration#3855
Open
KyleAMathews wants to merge 1 commit intomainfrom
Open
Add fast-loop detection and backoff for proxy misconfiguration#3855KyleAMathews wants to merge 1 commit intomainfrom
KyleAMathews wants to merge 1 commit intomainfrom
Conversation
…ations When a proxy or CDN is misconfigured (e.g., not including query params in cache keys, serving stale 409s), the client can get stuck in a tight retry loop hammering the server. This adds detection and backoff: - Tracks timestamps of recent non-live requests in #requestShape() - When 5+ requests happen within 500ms, applies exponential backoff (100ms base, 5s max) with full jitter - After 5 consecutive fast loops, throws a descriptive error explaining the likely cause and linking to the troubleshooting guide - Resets tracking when the stream reaches a healthy (up-to-date) state - Warning logged on first detection to help with debugging https://claude.ai/code/session_01PRpp3wmqC4DinxcmxDANLZ
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3855 +/- ##
==========================================
+ Coverage 69.43% 75.75% +6.32%
==========================================
Files 6 11 +5
Lines 386 693 +307
Branches 96 172 +76
==========================================
+ Hits 268 525 +257
- Misses 117 167 +50
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
This PR adds detection and mitigation for tight retry loops caused by proxy or CDN misconfiguration. When the client detects a pattern of rapid non-live requests, it applies exponential backoff and eventually throws an error with diagnostic information to help users troubleshoot their infrastructure.
Key Changes
FetchErrorwith detailed diagnostic guidance pointing to common proxy/CDN issues (missing cache key parameters, stale responses, stripped headers).Implementation Details
!this.#syncState.isUpToDate) to avoid flagging normal live polling as problematichttps://claude.ai/code/session_01PRpp3wmqC4DinxcmxDANLZ