ofetch
ofetch copied to clipboard
feat: support callback in retryDelay
๐ Linked issue
โ Type of change
- [ ] ๐ Documentation (updates to the documentation, readme, or JSdoc annotations)
- [ ] ๐ Bug fix (a non-breaking change that fixes an issue)
- [ ] ๐ Enhancement (improving an existing functionality like performance)
- [x] โจ New feature (a non-breaking change that adds functionality)
- [ ] ๐งน Chore (updates to the build process or auxiliary tools and libraries)
- [ ] โ ๏ธ Breaking change (fix or feature that would cause existing functionality to change)
๐ Description
Calculate retry delay based on context. Opens possibility to make retries with incremental delay. For example:
{
retry: 3,
retryDelay: (context) => {
const attempt = context.options.retryAttempt = (context.options.retryAttempt || 0) + 1;
return 300 * (Math.pow(3, attempt - 1))
},
}
๐ Checklist
- [ ] I have linked an issue or discussion.
- [ ] I have updated the documentation accordingly.
Though I don't like having this context.options "hack". Would be nice to have shared context between retries.