platform-bible-utils
    Preparing search index...

    Function retryUntil

    • Repeatedly runs an async attempt until its result is accepted or the attempt budget is exhausted, waiting a fixed delay between tries (never after the last). Always resolves to the last result — it never throws on exhaustion, so the caller decides what a give-up result means.

      This is the fixed-attempts + fixed-delay retry shape shared by flaky-startup probes (e.g. resolveRegistrationValidity, and the missing-handler retry in requestWithRetry). For deadline- or abort-driven retries with variable backoff (e.g. requestSessionSyncWithBootRetry in startup-tasks), use a bespoke loop instead — this helper deliberately does not cover those.

      Type Parameters

      • TResult

      Parameters

      • attempt: (attemptNumber: number) => Promise<TResult>

        Runs one try; receives the 1-based attempt number and resolves to a result.

      • isDone: (result: TResult) => boolean

        Returns true when attempt's result is acceptable and retrying should stop.

      • Optionaloptions: { delayMs?: number; maxAttempts?: number }
        • OptionaldelayMs?: number

          Delay between tries. Defaults to 0.

        • OptionalmaxAttempts?: number

          Total tries; clamped to at least 1. Defaults to 3.

      Returns Promise<TResult>

      The first accepted result, or the last attempt's result if none qualified.