Basic Retry Configuration
Configure retries using themaxRetries
option:
Default Behavior
- Default retries: 3 attempts (configurable 0-10)
- Retry trigger: Any thrown exception
- Success condition: Task returns without throwing
- Backoff strategy: Exponential backoff (built-in)
Exponential Backoff
The TypeScript SDK implements exponential backoff automatically:- First 5 failures: No delay (offset period)
- After offset: 1.5s, 3s, 4.5s, 6s… up to 15s max
- Backoff resets on successful execution
Retry Patterns
Conditional Retries
Control which errors trigger retries:Return vs Throw
Control retry behavior with return values:Using Attempt Number
Access the current attempt for custom logic:Common Retry Scenarios
External API Calls
Database Operations
File Processing
Best Practices
-
Set Appropriate Retry Limits
-
Consider Idempotency
-
Log Retry Attempts
-
Handle Final Failures
Limitations
- Max retries: Limited to 10 attempts
- No custom backoff: Exponential backoff is built-in and not configurable
- All exceptions retry: Cannot configure which error types retry
- No retry delay control: Cannot set custom delays between retries