mise API - v0.0.0
    Preparing search index...

    Function retry_untilValue

    • Runs fn up to attempts times, sleeping between attempts, until it yields a non-null value.

      The delay before retry N (1-based) is delaysMs[N-1], with the last entry reused when attempts outnumber delays; no sleep precedes the first attempt.

      Type Parameters

      • T

      Parameters

      • attempts: number

        Maximum number of attempts (at least 1).

      • delaysMs: readonly number[]

        Backoff delays in milliseconds between attempts.

      • fn: (attempt: number) => Promise<T | null>

        The operation; null means "failed, retry if attempts remain". Receives the 0-based attempt index.

      Returns Promise<T | null>

      The first non-null value, or null when every attempt failed.

      const record = await retry_untilValue(3, [250, 500], () => record_fetch(id));