UNPKG

@tanstack/offline-transactions

Version:

Offline-first transaction capabilities for TanStack DB

23 lines (22 loc) • 870 B
import { NonRetriableError } from "../types.js"; import { BackoffCalculator } from "./BackoffCalculator.js"; // src/retry/RetryPolicy.ts var DefaultRetryPolicy = class { constructor(maxRetries = Number.POSITIVE_INFINITY, jitter = true) { this.backoffCalculator = new BackoffCalculator(jitter); this.maxRetries = maxRetries; } calculateDelay(retryCount) { return this.backoffCalculator.calculate(retryCount); } shouldRetry(error, retryCount) { if (retryCount >= this.maxRetries) return false; if (error instanceof NonRetriableError) return false; if (error.name === `AbortError`) return false; if (error.message.includes(`401`) || error.message.includes(`403`)) return false; if (error.message.includes(`422`) || error.message.includes(`400`)) return false; return true; } }; export { DefaultRetryPolicy }; //# sourceMappingURL=RetryPolicy.js.map