AniLink - v3.0.0
    Preparing search index...

    Function awaitPaceDeadline

    • Awaits the recorded rate-limit reset deadline for the caller's owner and host, when one is still in the future, before the caller dispatches its request. The sleep carries a small random stagger on top of the deadline wait so requests queued on one window reset wake spread across a short interval instead of firing at the identical millisecond; the onPace payload reports the true deadline wait, not the staggered sleep, so pacing metrics stay comparable. Emits onPace once for each wait, keeping an intentional rate-limit wait distinct from a hung request in hook-based metrics. A wait aborted partway through emits onPace with the elapsed portion of the deadline wait (clamped, so an abort landing inside the stagger window never reports more than the deadline wait itself) and aborted: true before surfacing as a pacing abort (abortedDuringPacing), so a cancelled wait stays distinguishable both from a cancelled in-flight request and from no pacing at all.

      Returns the observed portion of the deadline wait, excluding the stagger, so the caller's cumulative pacing metrics (pacedMs) match the measure onPace reports. Returns 0 when no wait was needed.

      Parameters

      • owner: object | undefined

        The caller's stable transport-settings object, when known.

      • host: string

        The upstream host the request is dispatched to.

      • resolved: ResolvedRequestOptions

        The resolved request options carrying the pacing flag and hooks.

      • hookContext: RequestContext

        The attempt's request context, reused for the onPace emission.

      Returns Promise<number>

      The observed deadline wait in milliseconds, stagger excluded; 0 when the dispatch was not paced.