JavaScript
Collect successes and failures with Promise.allSettled
Use Promise.allSettled when every task outcome matters, including failures. It waits for all inputs and returns a status record for each one in input order.
Worked example
Node.js example · save as example.mjs and run node example.mjs
const results = await Promise.allSettled([
Promise.resolve("ready"), Promise.reject(new Error("missing"))
]);
console.log(results.map(item => item.status).join(","));
console.log(results[0].value);How it works
A fulfilled entry contains value, while a rejected entry contains reason. This makes partial-result workflows explicit: successful items can be kept while failures are reported or retried. Inspect each record instead of assuming the combined await implies success.
Limits and mistakes
The call still waits forever if one input never settles. It does not create timeouts or control concurrency. Add cancellation or a task-specific deadline for operations that might hang, and avoid swallowing every error without reporting it.
Check the result
Expect fulfilled,rejected and ready. Check both branches in your consumer, and make sure a failed result cannot accidentally be treated as a successfully loaded record.
Sources
Reference documentation for the behavior used in this guide: