-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Labels
enhancementNew feature or requestNew feature or request
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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request