/** * Error thrown when a fetch request fails with a non-retryable status code. */ export declare class HttpFetchError extends Error { response: Response; status: number; constructor(message: string, response: Response); } /** * Performs a fetch request with automatic retry logic for transient failures. * * This function automatically retries fetch requests that fail with retryable HTTP * status codes (408, 429, 500, 502, 503, 504). Client errors (4xx except 408/429) * and successful responses are not retried. * * @param input - The URL or Request object to fetch * @param init - Optional fetch configuration (headers, method, body, etc.) * @param options - Retry configuration options * @param options.retries - Maximum number of retry attempts (default: 3) * @param options.delayMs - Initial delay between retries in milliseconds (default: 1000) * @param options.exponentialBackoff - Whether to double the delay after each retry (default: true) * @returns A promise that resolves with the Response object on success * @throws {HttpFetchError} If the request fails with a non-retryable status code * @throws {RetryError} If all retry attempts are exhausted for a retryable status code * @throws {TypeError} If the fetch request fails due to network issues * * @example * ```ts * // Simple usage with defaults (3 retries, 1s delay, exponential backoff) * const response = await fetchWithExponentialTimeout('https://api.example.com/data') * const data = await response.json() * ``` * * @example * ```ts * // Custom retry configuration * const response = await fetchWithExponentialTimeout( * 'https://api.example.com/data', * { method: 'POST', body: JSON.stringify({ key: 'value' }) }, * { retries: 5, delayMs: 500, exponentialBackoff: true } * ) * ``` * * @example * ```ts * // Handling errors * try { * const response = await fetchWithExponentialTimeout('https://api.example.com/data') * const data = await response.json() * } catch (error) { * if (error instanceof HttpFetchError) { * console.error(`HTTP ${error.status}: ${error.message}`) * } else if (error instanceof RetryError) { * console.error('All retry attempts exhausted') * } else { * console.error('Network error:', error) * } * } * ``` */ export declare function fetchWithExponentialTimeout(input: RequestInfo | URL, init?: RequestInit, options?: { retries?: number; delayMs?: number; exponentialBackoff?: boolean; maxDelayMs?: number; }): Promise;