Function: retryableHttpRequest()
Gala Launchpad SDK 9.0.0-rc.5 / index / retryableHttpRequest
Function: retryableHttpRequest()
retryableHttpRequest<
T>(fn,options?):Promise<T>
Defined in: packages/launchpad-sdk/dist/utils/api-patterns.d.ts:231
HTTP request wrapper with automatic retry logic
Wraps async functions with exponential backoff retry on specific HTTP status codes. Helps handle transient failures like rate limiting, timeouts, and temporary service issues.
Type Parameters
T
T
Type of the promised value
Parameters
fn
() => Promise<T>
Async function to execute with retries
options?
Retry configuration
backoffMs?
number
Initial backoff delay in milliseconds (default: 100)
maxRetries?
number
Maximum number of retry attempts (default: 3)
retryableStatus?
number[]
HTTP status codes to retry (default: [429, 503, 504])
Returns
Promise<T>
Result of the function or final error after max retries
Throws
Error if all retries exhausted or error is not retryable
Examples
Retry on rate limit (429)
const result = await retryableHttpRequest(
() => sdk.fetchTokenPrice('anime'),
{ maxRetries: 3, backoffMs: 100, retryableStatus: [429, 503] }
);
With default retry options
const result = await retryableHttpRequest(
() => http.get('/api/pool-data')
);
// Retries on 429, 503, 504 with default exponential backoff
Fetch with custom retry behavior
try {
const data = await retryableHttpRequest(
() => fetch(url).then(r => r.json()),
{ maxRetries: 5, backoffMs: 200, retryableStatus: [429, 500, 502, 503, 504] }
);
} catch (error) {
console.log('Failed after all retries:', error);
}
Since
6.5.0 @adoption_gap Manual retry logic appears in 3+ locations