Promise.race()
A function that returns a promise that settles as soon as the first of several promises settles.
In more detail
The returned promise follows whichever input settles first, fulfilled or rejected. It was the traditional way to add timeouts, but it does not cancel the losing work; AbortSignal.timeout() and AbortSignal.any() do.
Related terms
- Promise — A JavaScript object that stands for a result that is not ready yet and will later either succeed with a value or fail with an error.
- AbortSignal.any() — A function that combines several signals into one that aborts as soon as any of them does.
Taught in
- Cancellation With AbortController And Async Signal Propagation — Frontend Architecture & Web Platform