fix(appkit): add jitter to RetryInterceptor exponential backoff#269
Merged
MarioCadenas merged 2 commits intomainfrom Apr 13, 2026
Merged
fix(appkit): add jitter to RetryInterceptor exponential backoff#269MarioCadenas merged 2 commits intomainfrom
MarioCadenas merged 2 commits intomainfrom
Conversation
RetryInterceptor used pure exponential backoff (initialDelay * 2^attempt), causing all concurrent retries to fire at identical intervals after a simultaneous failure (thundering herd). Now applies full jitter by default: delay * (0.5 + Math.random() * 0.5), producing random delays between 50% and 100% of the base delay. Opt out with retry.jitter = false. Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
ditadi
approved these changes
Apr 13, 2026
Contributor
ditadi
left a comment
There was a problem hiding this comment.
Sounds good, I just added two points.
Address PR review feedback: - Use true full jitter (capped * Math.random()) giving range [0, capped] instead of half jitter (50%-100%) - Remove jitter boolean flag — jitter is always applied since it is strictly better for production retry behavior Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
Collaborator
Author
addressed, thank you! |
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
The
RetryInterceptorused pure exponential backoff (initialDelay * 2^attempt), causing all concurrent retries after a simultaneous failure to fire at identical intervals — a thundering herd problem. This PR adds full jitter by default: each retry delay is randomized between 50% and 100% of the computed backoff value, spreading retries over time.Changes
jitter?: booleanfield toRetryConfig(defaults totrue)RetryInterceptor.calculateDelay()to apply random jitter:capped * (0.5 + Math.random() * 0.5)jitter: falsewhere exact timing is assertedMath.random() = 0(50%) andMath.random() = 1(100%)Test plan
jitter: false)jitter: falseproduces deterministic delays identical to prior behavior