staggeredRace
staggeredRace<
Candidate,Result>(candidates,attempt,options):Promise<Result>
Defined in: packages/async/src/race/staggered-race.ts:38
Try candidates in order, starting the next one when the previous has not
succeeded within delayMs — or at once when it fails — and settle with the
first success: RFC 8305 “Happy Eyeballs” connection racing, for any
candidates.
Losing attempts are aborted through the signal passed to attempt. Starts at
most candidates.length attempts; time is bounded by the slowest attempt
only when all fail.
Type Parameters
Section titled “Type Parameters”Candidate
Section titled “Candidate”Candidate
Result
Section titled “Result”Result
Parameters
Section titled “Parameters”candidates
Section titled “candidates”readonly Candidate[]
What to try, in order of preference.
attempt
Section titled “attempt”MaybeAsyncCallable<[Candidate, AbortSignal], Result>
Tries one candidate; must honour signal.
options
Section titled “options”StaggeredRaceOptions<Result>
The stagger delay, and how to dispose of late successes.
Returns
Section titled “Returns”Promise<Result>
The first successful result.
Throws
Section titled “Throws”The only attempt’s error when there is one candidate, an
AggregateError of every attempt’s error otherwise, or signal’s reason.