Add `retryAttempt` to `FetchContext`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 195
- PR merge metrics
- No merged PRs in 30d
Description
Describe the feature
PR #372 added the ability to pass a callback to retryDelay, which should enable exponential backoff, but currently it's tricky to implement. I couldn't find an option to get the current attempt in this callback. The mentioned PR calls for context.options.retryAttempt, which doesn't exist.
I am currently using a workaround:
function exponentialBackoff(baseRetries: number, baseDelay = 1_000) {
return (context: FetchContext<any, 'json'>) => {
const retryLeft = context.options.retry || 0
const currentRetry = baseRetries - retryLeft
return baseDelay * 2 ** currentRetry
}
}
Additional information
- Would you be willing to help implement this feature?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing FetchContext and the retryDelay callback behavior described in PR #372, then locate where retry options are assembled. Add the current retry attempt to context.options so exponential backoff callbacks can use it, and verify that retryDelay receives the expected value across retries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100