Home

PromiseallSettled

Promise.allSettled is a Promise utility that accepts an iterable of promises (and/or values) and returns a single promise that resolves after all input promises have settled, either fulfilled or rejected. When fulfilled, the returned value is an array describing the outcome of each input in the same order as provided. Each element is an object of the form { status: 'fulfilled', value: ... } or { status: 'rejected', reason: ... }.

Unlike Promise.all, which rejects as soon as one input rejects, allSettled waits for every input to settle.

Common use cases include performing multiple asynchronous operations in parallel and collecting all results, including failures,

Example:

Promise.allSettled([Promise.resolve(1), Promise.reject(new Error('oops')), 3]).then(results => console.log(results));

This prints an array like:

[

{ status: 'fulfilled', value: 1 },

{ status: 'rejected', reason: Error('oops') },

{ status: 'fulfilled', value: 3 }

]

See also: Promise.all, Promise.any, Promise.race.

Non-promise
values
are
treated
as
fulfilled,
with
their
value
reflected
in
the
corresponding
array
element.
It
was
standardized
in
ES2020
and
is
supported
in
modern
browsers
and
in
Node.js
(12+).
for
reporting
or
aggregated
processing.
This
avoids
the
need
to
short-circuit
on
the
first
failure.