MCPcopy Create free account
hub / github.com/pollinations/pollinations / retryWithBackoff

Function retryWithBackoff

shared/events.ts:229–245  ·  view source on GitHub ↗
(
    attempt: number,
    log: Logger,
    message: string,
    status?: number,
)

Source from the content-addressed store, hash-verified

227}
228
229async function retryWithBackoff(
230 attempt: number,
231 log: Logger,
232 message: string,
233 status?: number,
234): Promise<void> {
235 const delay = exponentialBackoffDelay(attempt, {
236 minDelay: MIN_DELAY,
237 maxDelay: MAX_DELAY,
238 maxAttempts: MAX_RETRIES,
239 });
240
241 const logData = status ? { status, attempt, delay } : { attempt, delay };
242
243 log.warn(`${message}: attempt={attempt} delay={delay}ms`, logData);
244 await new Promise((resolve) => setTimeout(resolve, delay));
245}
246
247async function delayForRetry(attempt: number): Promise<void> {
248 const delay = exponentialBackoffDelay(attempt, {

Callers 2

sendToTinybirdFunction · 0.85
sendTierEventToTinybirdFunction · 0.85

Calls 2

exponentialBackoffDelayFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected