How to fix Unhandled promise rejection from Promise.all() in Node.js

Node.jsINTERMEDIATEHIGHUpdated Dec 9, 2025· 170 views

Promise.all() rejects immediately when any single promise in the array rejects, causing an unhandled promise rejection if not properly caught. The entire operation fails even if other promises would have succeeded.

Quick fix

Fixes Unhandled promise rejection from Promise.all()

async function fetchData() {
  try {
    const results = await Promise.all([
      fetch('https://api.example.com/users'),
      fetch('https://api.example.com/posts'),
      fetch('https://api.example.com/comments')
    ]);

    console.log('All requests succeeded:', results);
    return results;
  } catch (error) {
    console.error('One or more promises failed:', error);
    // Handle the error appropriately
    throw error;
  }
}
  1. Add error handling with try/catch (async/await)
  2. Add .catch() handler to Promise.all()
  3. Use Promise.allSettled() for independent operations
  4. Add individual promise error handlers
node.js — error
async function fetchData() {
try {
const results = await Promise.all([
fetch('https://api.example.com/users'),
fetch('https://api.example.com/posts'),
fetch('https://api.example.com/comments')
]);
console.log('All requests succeeded:', results);
return results;
} catch (error) {
console.error('One or more promises failed:', error);
// Handle the error appropriately
throw error;
}
}
Unhandled promise rejection from Promise.all()

What this error means

Promise.all() uses an "all or nothing" approach to handle multiple promises concurrently. When you pass an array of promises to Promise.all(), it returns a single promise that resolves only when all input promises have resolved successfully. However, if any single promise rejects, Promise.all() immediately rejects with that first rejection reason, abandoning the results of all other promises. This behavior can catch developers off guard, especially when they expect all promises to complete regardless of individual failures. The rejected promise from Promise.all() must be handled with a .catch() handler or try/catch block (when using async/await), otherwise it becomes an unhandled promise rejection that can crash Node.js applications in strict mode or when --unhandled-rejections=strict is set. The other promises in the array continue to execute in the background, but their results are lost and inaccessible through the Promise.all() return value. This can lead to wasted resources and incomplete operations if those promises had side effects that needed to complete.

Typical symptoms

  • Node.js application crashes with "UnhandledPromiseRejectionWarning"
  • Promise.all() fails even though most promises in the array succeeded
  • Results from successful promises are lost when one promise fails
  • Error message shows only the first rejection, hiding other potential failures
  • Application exits with warning about unhandled rejections in newer Node.js versions

Common causes

  1. Missing .catch() handler on Promise.all() call
  2. Not wrapping Promise.all() in try/catch when using async/await
  3. One or more promises in the array rejects due to network errors, timeouts, or validation failures
  4. Expecting all promises to complete independently regardless of individual failures
  5. Using Promise.all() when Promise.allSettled() would be more appropriate for the use case

How to fix "Unhandled promise rejection from Promise.all()"

1Add error handling with try/catch (async/await)

Wrap your Promise.all() call in a try/catch block to handle rejections:

javascript
async function fetchData() {
  try {
    const results = await Promise.all([
      fetch('https://api.example.com/users'),
      fetch('https://api.example.com/posts'),
      fetch('https://api.example.com/comments')
    ]);

    console.log('All requests succeeded:', results);
    return results;
  } catch (error) {
    console.error('One or more promises failed:', error);
    // Handle the error appropriately
    throw error;
  }
}

This catches the first rejection and prevents an unhandled promise rejection.

2Add .catch() handler to Promise.all()

If not using async/await, attach a .catch() handler directly:

javascript
Promise.all([
  fetchUser(),
  fetchPosts(),
  fetchComments()
])
  .then(results => {
    console.log('All promises resolved:', results);
  })
  .catch(error => {
    console.error('Promise.all rejected:', error);
    // Handle the rejection
  });

The .catch() handler receives the first rejection reason from any failed promise.

3Use Promise.allSettled() for independent operations

If you need all promises to complete regardless of individual failures, use Promise.allSettled() instead:

javascript
async function fetchAllData() {
  const results = await Promise.allSettled([
    fetch('https://api.example.com/users'),
    fetch('https://api.example.com/posts'),
    fetch('https://api.example.com/comments')
  ]);

  results.forEach((result, index) => {
    if (result.status === 'fulfilled') {
      console.log(`Promise ${index} succeeded:`, result.value);
    } else {
      console.error(`Promise ${index} failed:`, result.reason);
    }
  });

  return results;
}

Promise.allSettled() never rejects—it waits for all promises to settle and returns an array of objects with status ('fulfilled' or 'rejected') and value/reason.

4Add individual promise error handlers

Handle errors at the individual promise level before passing to Promise.all():

javascript
async function safeFetch(url) {
  try {
    const response = await fetch(url);
    return { success: true, data: response };
  } catch (error) {
    return { success: false, error: error.message };
  }
}

const results = await Promise.all([
  safeFetch('https://api.example.com/users'),
  safeFetch('https://api.example.com/posts'),
  safeFetch('https://api.example.com/comments')
]);

// All promises always resolve, check success flag
const failed = results.filter(r => !r.success);
if (failed.length > 0) {
  console.log('Some requests failed:', failed);
}

This ensures Promise.all() never rejects while still tracking individual failures.

Advanced notes

Understanding Promise.all() short-circuit behavior: When Promise.all() rejects, it does so immediately upon the first rejection, but this doesn't cancel the other promises. They continue executing in the background, which can lead to race conditions or wasted resources. If you need to cancel pending operations when one fails, consider implementing an AbortController pattern.

Process-level unhandled rejection handling: In Node.js, you can add a global handler for unhandled rejections as a last resort:

javascript
process.on('unhandledRejection', (reason, promise) => {
  console.error('Unhandled Rejection at:', promise, 'reason:', reason);
  // Application specific logging, throwing an error, or other logic here
});

However, this is not a replacement for proper error handling—always handle rejections at the point they occur.

Promise.all vs Promise.allSettled vs Promise.race: Choose the right method for your use case:
- Promise.all(): Use when all promises must succeed for the operation to be valid (e.g., loading critical dependencies)
- Promise.allSettled(): Use when you want results from all promises regardless of success/failure (e.g., batch API calls to third parties)
- Promise.race(): Use when you only need the first promise to settle (e.g., timeout patterns, redundant requests)

Performance consideration: Promise.all() is more efficient than sequential await calls when promises are independent, as they run concurrently. However, if one promise is likely to fail quickly, consider running it first to fail fast before starting expensive operations.

Frequently asked questions

What does "Unhandled promise rejection from Promise.all()" mean?
all() uses an "all or nothing" approach to handle multiple promises concurrently. all(), it returns a single promise that resolves only when all input promises have resolved successfully. all() immediately rejects with that first rejection reason, abandoning the results of all other promises.
How do I fix "Unhandled promise rejection from Promise.all()"?
Promise.all() rejects immediately when any single promise in the array rejects, causing an unhandled promise rejection if not properly caught. The entire operation fails even if other promises would have succeeded.
What causes "Unhandled promise rejection from Promise.all()"?
Missing .catch() handler on Promise.all() call Not wrapping Promise.all() in try/catch when using async/await One or more promises in the array rejects due to network errors, timeouts, or validation failures
Is the "Unhandled promise rejection from Promise.all()" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading