-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Support for Backoff Mechanism in Retry Configuration #8095
Copy link
Copy link
Closed as duplicate of#8482
Copy link
Description
Clear and concise description of the problem
Vitest's retry option re-runs failed tests but lacks a configurable backoff strategy. Specifically, when testing against rate-limited APIs.
- Exceeding Rate Limits: Immediate retries often hit rate limits again, sending rapid, failing requests.
- API Blocking: Continuous retries can cause APIs to throttle or block further requests.
- Increased Test Run Time: Tests fail quickly without giving the API time to recover, especially problematic with shared database instances.
This limits the effectiveness of integration tests against external services, as transient network issues or API rate limits are not gracefully handled.
Suggested solution
Extend the retry configuration to include a configurable backoff strategy. This would allow Vitest to wait between retries, giving external services time to recover.
Benefits of this solution:
- Graceful API Interaction: Reduces load on rate-limited APIs, allowing recovery.
- Improved Test Reliability: Increases the chance of flaky tests passing due to temporary external service issues.
- Reduced API Abuse: Prevents accidental denial-of-service during test runs.
- Flexibility: Users can fine-tune the backoff strategy for specific API characteristics.
Alternative
// vitest.config.ts
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
// Existing retry count
retry: 3,
// New backoff configuration
retryBackoff: {
initialInterval: 1000, // Initial delay in ms (e.g., 1 second)
maxInterval: 15000, // Maximum delay in ms (e.g., 15 seconds)
exponent: 2, // Factor for interval increase (e.g., exponential backoff)
},
// ... other test options
},
});Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Reactions are currently unavailable