Retry an async operation with a fixed delay between attempts.
Useful for working around transient sandbox concurrency limits: when a provider rejects creation because the organisation has too many running sandboxes, waiting a short while and retrying usually succeeds once a previous sandbox finishes shutting down.
withRetry<
T
>(
fn: () => Promise<T>, maxRetries: number = DEFAULT_MAX_RETRIES, delayMs: number = DEFAULT_RETRY_DELAY_MS
): Promise<T>| Name | Type | Description |
|---|---|---|
fn* | () => Promise<T> | The async operation to attempt |
maxRetries | number | Default: DEFAULT_MAX_RETRIESMaximum number of attempts (default: 3) |
delayMs | number | Default: DEFAULT_RETRY_DELAY_MSMilliseconds to wait between attempts (default: 10 000) |
const sandbox = await withRetry(() => DenoSandbox.create({ memoryMb: 768 }));