---
title: "Promise.all vs Promise.allSettled vs Promise.any vs Promise.race"
description: "All four combine several promises into one, but they settle differently on success and failure. Learn what each returns and which one to pick for your case."
url: https://www.danny.engineering/answer/javascript/promiseall-vs-promiseallsettled-vs-promiseany-vs-promiserace
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T17:24:00.000Z
tags: ["Javascript"]
---

# Promise.all vs Promise.allSettled vs Promise.any vs Promise.race

## The short answer


All four take a list of promises and return one promise. They differ in when that promise settles and what it gives you:

- `Promise.all`: waits for every promise to fulfil. Rejects as soon as any one rejects.
- `Promise.allSettled`: waits for every promise to finish, whatever happens. Never rejects.
- `Promise.any`: fulfils with the first promise to fulfil. Rejects only if all of them reject.
- `Promise.race`: settles the same way as the first promise to settle, success or failure.

```javascript
const [user, posts] = await Promise.all([loadUser(id), loadPosts(id)]);
```


## Why it happens


When you start several async tasks at once, you have to decide what "done" means. Do you need every result, or just one? Should a single failure stop everything? Each combinator answers those questions differently, and choosing the wrong one leads to lost errors or hanging pages.


None of them cancel the other promises. When `Promise.all` rejects early, the other requests keep running in the background; their results are just ignored. Use an `AbortController` if you need to stop them.


## How to fix it


### Promise.all: you need every result


Use it when the results depend on each other and one failure means the whole task has failed, such as loading the data a page cannot render without.


```javascript
try {
  const [user, settings] = await Promise.all([loadUser(), loadSettings()]);
  render(user, settings);
} catch (error) {
  showError(error); // the first rejection
}
```


The results come back in the same order as the input, not the order they finished.


### Promise.allSettled: you want every outcome


Use it when tasks are independent and you want to report on each one, such as uploading a batch of files.


```javascript
const results = await Promise.allSettled(files.map(upload));

const failed = results
  .map((result, index) => ({ result, file: files[index] }))
  .filter(({ result }) => result.status === 'rejected');

for (const { file, result } of failed) {
  console.warn(`${file.name} failed`, result.reason);
}
```


Each result is an object with a `status` of `'fulfilled'` and a `value`, or `'rejected'` and a `reason`.


### Promise.any: the first success is enough


Use it when several sources can provide the same thing and you want the fastest one that works, such as mirrors or fallback endpoints.


```javascript
try {
  const response = await Promise.any([
    fetch('https://cdn-a.example.com/data.json'),
    fetch('https://cdn-b.example.com/data.json'),
  ]);
  console.log(await response.json());
} catch (error) {
  // AggregateError: every promise rejected
  console.error(error.errors);
}
```


### Promise.race: the first to finish, either way


Use it when the first outcome wins even if it is an error. The classic use is a timeout, although `AbortSignal.timeout` is now the better tool for `fetch`.


```javascript
function timeout(ms) {
  return new Promise((_, reject) =>
    setTimeout(() => reject(new Error('Timed out')), ms),
  );
}

const result = await Promise.race([slowTask(), timeout(5000)]);
```


## Common pitfalls

- Expecting `Promise.all` to stop the other tasks after a failure. It does not cancel anything.
- Using `Promise.all` for independent tasks, so one failure hides every successful result. Use `allSettled` instead.
- Mixing up `any` and `race`. `race` settles on the first rejection too; `any` ignores rejections until all have failed.
- Passing an empty array. `Promise.all([])` and `allSettled([])` fulfil straight away, `any([])` rejects with an `AggregateError`, and `race([])` never settles.
- Awaiting promises one by one in a loop when they do not depend on each other. Start them together and combine them.

## Related reading

- [MDN: Promise.all()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
- [MDN: Promise.allSettled()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled)
- [MDN: Promise.any()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any)
