Function: withRetry()
withRetry<
T>(operation: () =>Promise<T>,config:WithRetryConfig):Promise<T>
Defined in: utils.ts:538
Executes an async operation with retry logic and exponential backoff. Only retries on transient errors (as determined by shouldRetry from errors/utils).
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
operation | () => Promise<T> | Async function to execute |
config | WithRetryConfig | Retry configuration |
Returns
Promise<T>
Promise resolving to the operation result
Throws
The last error encountered after all retries are exhausted
Example
TypeScript
const result = await withRetry(
() => apiClient.getMessageById(id),
{
maxRetries: 3,
initialDelayMs: 1000,
backoffMultiplier: 2,
maxDelayMs: 30000,
respectRetryAfterHint: true,
}
)