feature: Exponential Backoff And Jitter#582
Conversation
Signed-off-by: ysknsid25 <kengo071225@gmail.com>
📝 WalkthroughWalkthroughAdds opt-in exponential backoff with jitter strategies (full-jitter, equal-jitter, decorrelated-jitter) to the retry mechanism via new ChangesRetry Backoff with Jitter
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #582 +/- ##
===========================================
+ Coverage 56.86% 86.66% +29.79%
===========================================
Files 16 6 -10
Lines 728 285 -443
Branches 113 140 +27
===========================================
- Hits 414 247 -167
+ Misses 303 33 -270
+ Partials 11 5 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/retry.ts`:
- Around line 11-14: The JSDoc for the `base` field is misleading: update the
comment for `base` (in src/retry.ts) to explain it is the base/backoff factor
used to compute retry delays rather than a guaranteed minimum delay — explicitly
state that for jitter strategies like `full-jitter` and `equal-jitter` computed
delays can be below `base` (even 0); keep `cap` description as the upper bound.
Mention the relevant symbols `base`, `cap`, and the jitter strategies
(`full-jitter`, `equal-jitter`) so readers understand the semantics.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 19017108-30b1-49e8-bbb6-ac238b81518b
📒 Files selected for processing (6)
README.mdsrc/fetch.tssrc/retry.tssrc/types.tstest/index.test.tstest/retry.test.ts
| /** Minimum delay in milliseconds. */ | ||
| base: number; | ||
| /** Maximum delay in milliseconds. */ | ||
| cap: number; |
There was a problem hiding this comment.
Clarify base semantics in API docs.
base is not a strict minimum delay for full-jitter and equal-jitter (those can go below base, including 0). Please reword this to avoid misleading users.
Suggested wording
- /** Minimum delay in milliseconds. */
+ /** Base delay in milliseconds used by backoff calculations. */
base: number;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** Minimum delay in milliseconds. */ | |
| base: number; | |
| /** Maximum delay in milliseconds. */ | |
| cap: number; | |
| /** Base delay in milliseconds used by backoff calculations. */ | |
| base: number; | |
| /** Maximum delay in milliseconds. */ | |
| cap: number; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/retry.ts` around lines 11 - 14, The JSDoc for the `base` field is
misleading: update the comment for `base` (in src/retry.ts) to explain it is the
base/backoff factor used to compute retry delays rather than a guaranteed
minimum delay — explicitly state that for jitter strategies like `full-jitter`
and `equal-jitter` computed delays can be below `base` (even 0); keep `cap`
description as the upper bound. Mention the relevant symbols `base`, `cap`, and
the jitter strategies (`full-jitter`, `equal-jitter`) so readers understand the
semantics.
resolves: #581
Summary by CodeRabbit
New Features
retryBackoffconfiguration takes precedence overretryDelayfor advanced retry controlDocumentation