Promise.any(promises) returns a promise that fulfills with the value of the first promise that fulfills. Rejections are skipped while there is still a chance of success. Only when every promise has rejected does it reject, with an AggregateError whose errors array holds all the reasons in input order. Think of it as "the first success wins".
Remember
Promise.any([a, b, c]) -> one promise
first FULFILLED value wins
rejections are ignored...
...unless ALL reject -> AggregateError
error.errors -> every reason, input order
[] -> rejects (AggregateError)
Syntax
Call it on Promise with an array (or any iterable) of promises.
JavaScript
Promise.any(iterable)
const first = await Promise.any(iterable);
Call
What it does
Promise.any([p1, p2, p3])
Fulfill with the first value that arrives successfully.
error.errors
In catch: the array of all rejection reasons.
Promise.any([])
Rejects right away with an AggregateError.
A static method added in ES2021, together with the AggregateError class.
Library declarations
JavaScript
Promise.any(iterable) // returns a Promise
// fulfills with: the value of the first promise that fulfills
// rejects with: AggregateError (when all reject, or iterable is empty)
// error.errors = [reason1, reason2, ...]
Parameters
Parameter
Description
iterable
An array (or other iterable) of promises. Plain values count as already fulfilled, so the first plain value wins.
Return Value
Return Value
Description
Promise
Fulfills with the first fulfilled value, or rejects with an AggregateError when no promise fulfills.
JavaScript Examples
Example 1 — Download from the Fastest Working Mirror
Three download servers are tried at once. The quickest one is down; the next quickest one wins.
An empty list fails at once.Promise.any([]) has nothing that could fulfill, so it rejects immediately and its catch prints before any timer fires.
race() takes the first outcome. After 30 ms the quick failure settles first, so Promise.race rejects with it.
any() waits for success.Promise.any skips that failure and fulfills at 60 ms with slow success.
Compatibility
Browser & Runtime Support
Promise.any() and AggregateError were added in ES2021.
✓ Widely available · ES2021
Promise.any()
Supported in all current browsers and in Node.js 15 and newer. The examples were run on Node.js 24.
WideAll current browsers
Google ChromeChrome 85+
Supported
Mozilla FirefoxFirefox 79+
Supported
Apple SafariSafari 14.1+
Supported
Microsoft EdgeEdge 85+
Supported
Node.jsNode.js 15+
Supported
DenoRecent versions
Supported
Internet ExplorerNo support
Not supported
Promise.any()Very good
Bottom line: Safe for current browsers. For browsers from before 2020, use a polyfill or Promise.allSettled() and pick the first fulfilled entry yourself.
Frequently Asked Questions
A promise that fulfills with the value of the first input promise that fulfills. Rejections are ignored as long as another promise can still succeed.
An error that wraps several errors. Promise.any rejects with one when every input rejects, and its errors property lists all the rejection reasons.
Promise.race settles with the first promise that settles, success or failure. Promise.any waits for the first success and only fails when everything fails.
It rejects right away with an AggregateError, because no promise can ever fulfill.
No. The other tasks keep running; their results are simply ignored once the first success has arrived.