Core - v1.3.2
    Preparing search index...

    Class Retry

    Retries an operation with a bounded attempt count and exponential backoff.

    Reads delivery.retries and delivery.retryBackoffMs inside each call, after application configuration. Callers can override either setting in RetryOptions.

    The default policy identifies HTTP failures by an Error's numeric status field. Supply isRetryable for application-specific failures.

    Operations must be safe to repeat. Callers are responsible for idempotent writes.

    const body = await Retry.run(() => client.get(url), { logger: log, event: 'rates.retry' })
    

    Bayu Dwiyan Satria

    1.3.1

    1.3.1

    Index
    • The default judgement on whether a failure is transient.

      Parameters

      • error: unknown

        The thrown value.

      Returns boolean

      true when another attempt is reasonable.

      An abort or a timeout is not retryable: the caller's own timeout already spent the budget it allowed.

      An Error with a numeric status is read as an HTTP failure, and retried only for 429 and the 5xx gateway family.

      Anything else is treated as a network failure and retried, which is the safe reading — fetch rejects for DNS, TLS and connection resets, and all three are worth a second look.

    • Runs an operation, retrying failures judged transient.

      Type Parameters

      • T

        The operation's result.

      Parameters

      • operation: () => Promise<T>

        The work to attempt. Must be safe to run more than once.

      • options: RetryOptions = {}

        Overrides for the resolved delivery defaults.

      Returns Promise<T>

      Whatever the operation returned.

      Backoff doubles: with the shipped defaults that is one attempt, 250 ms, a second, 500 ms, a third. The last failure is rethrown unchanged, so the caller sees the real cause rather than a wrapper.

      The final failure, once the budget is spent or the failure is not retryable.

      ConfigurationError When delivery is not registered and either attempts or backoffMs was left to default.