Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support retryDelay with callback function #372

Merged
merged 1 commit into from
May 16, 2024
Merged

Conversation

escral
Copy link
Contributor

@escral escral commented Mar 5, 2024

πŸ”— 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)
  • ✨ 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.

@escral escral marked this pull request as ready for review March 5, 2024 18:04
@escral
Copy link
Contributor Author

escral commented Mar 5, 2024

Though I don't like having this context.options "hack". Would be nice to have shared context between retries.

@pi0 pi0 changed the title feat: support callback in retryDelay feat: support retryDelay with callback function May 16, 2024
@pi0 pi0 merged commit 9a5640c into unjs:main May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants