Skip to content
Velloreth
Programming 7 min read

Promises vs Async/Await: Which to Use and When

Promises and async/await solve the same problem in different styles. Learn how each works, the pitfalls of both, and how to choose.

By

The problem both solve

JavaScript is single-threaded. When you make a network request, the runtime cannot block waiting for the response, because that would freeze everything else. So asynchronous operations return immediately and deliver their result later.

The original solution was callbacks, which led to deeply nested code:

getUser(id, (err, user) => {
  if (err) return handle(err);
  getPosts(user.id, (err, posts) => {
    if (err) return handle(err);
    getComments(posts[0].id, (err, comments) => {
      if (err) return handle(err);
      render(comments);
    });
  });
});

This is callback hell: three levels deep for three operations, with error handling repeated at every level.

Promises and async/await are two answers to the same problem.

Promises

A promise is an object representing a value that will exist later. It is in one of three states:

  • pending — not yet settled
  • fulfilled — resolved with a value
  • rejected — failed with a reason

Once settled, a promise never changes state.

fetch('/api/user')
  .then((response) => response.json())
  .then((user) => console.log(user))
  .catch((error) => console.error(error))
  .finally(() => console.log('done'));

The chain flattens the nesting. Each then returns a new promise, so errors propagate down to a single catch.

Creating a promise

function delay(ms) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

function fetchWithTimeout(url, ms) {
  return new Promise((resolve, reject) => {
    const timer = setTimeout(() => reject(new Error('Timeout')), ms);
    fetch(url)
      .then((res) => { clearTimeout(timer); resolve(res); })
      .catch((err) => { clearTimeout(timer); reject(err); });
  });
}

You rarely construct promises directly. Most come from APIs like fetch, fs.promises, or database clients.

async/await

async/await is syntax over promises. An async function always returns a promise, and await unwraps one.

async function loadUser(id) {
  try {
    const response = await fetch(`/api/user/${id}`);
    const user = await response.json();
    return user;
  } catch (error) {
    console.error(error);
    throw error;
  }
}

The same logic as the promise chain, but it reads like synchronous code. Errors use try/catch instead of .catch(). The nesting is gone.

What await actually does

await pauses the current async function until the promise settles. It does not block the program — other code continues to run. Only the async function is suspended.

async function example() {
  console.log('before');
  await delay(1000);
  console.log('after'); // runs 1 second later
}

example();
console.log('outside'); // runs immediately, before 'after'

The output order is before, outside, after. The await suspends example but not the caller.

They are the same thing

It is worth being explicit: async/await is not a different mechanism. It is syntax that compiles to promise chains.

// These are equivalent
async function a() {
  const x = await getX();
  return x + 1;
}

function b() {
  return getX().then((x) => x + 1);
}

Both return a promise. Both have the same performance. The difference is readability.

This means you can mix them freely:

async function mixed() {
  const user = await getUser();          // await a promise
  return getPosts(user.id).then((p) => p.length); // then on a promise
}

The concurrency trap

This is the most important practical difference, and it is not about syntax at all.

// Sequential: 3 seconds total
async function sequential() {
  const a = await fetchA(); // 1s
  const b = await fetchB(); // 1s
  const c = await fetchC(); // 1s
  return [a, b, c];
}

Each await waits for the previous one. If the operations are independent, this wastes time.

// Concurrent: 1 second total
async function concurrent() {
  const [a, b, c] = await Promise.all([fetchA(), fetchB(), fetchC()]);
  return [a, b, c];
}

Promise.all starts all three immediately and waits for all of them. Total time is the slowest one, not the sum.

This is the single biggest performance win available in async code, and it is easy to miss because the sequential version looks natural.

The combinators

MethodResolves whenRejects when
Promise.allAll fulfilAny rejects
Promise.allSettledAll settleNever
Promise.raceFirst settlesFirst rejects
Promise.anyFirst fulfilsAll reject

Promise.allSettled is the one people forget. When you want all results regardless of individual failures:

const results = await Promise.allSettled([fetchA(), fetchB(), fetchC()]);
for (const result of results) {
  if (result.status === 'fulfilled') console.log(result.value);
  else console.error(result.reason);
}

Promise.any is useful for racing redundant sources — take whichever responds first.

Error handling

With promises

fetchUser(id)
  .then(process)
  .catch(handleError);

A single catch at the end handles errors from any step in the chain.

With async/await

try {
  const user = await fetchUser(id);
  process(user);
} catch (error) {
  handleError(error);
}

The try/catch covers every await inside it.

The forgotten catch

// Bug: no error handling
async function load() {
  const data = await fetchData(); // if this rejects, the error is unhandled
}

An unhandled rejection in Node terminates the process by default. In browsers it logs a warning and continues, which is worse because the failure is silent.

Every async function that can reject needs a handler somewhere. Either wrap the body in try/catch, or ensure the caller handles the returned promise.

Errors inside Promise.all

try {
  const results = await Promise.all([a(), b(), c()]);
} catch (error) {
  // only the first rejection is caught; the others are lost
}

Promise.all rejects on the first failure, and the other promises continue running but their results are discarded. If you need every outcome, use allSettled.

Common mistakes

Awaiting in a loop when you could run concurrently.

// Slow: sequential
for (const id of ids) {
  results.push(await fetchItem(id));
}

// Fast: concurrent
const results = await Promise.all(ids.map((id) => fetchItem(id)));

Forgetting that forEach does not await.

// Bug: forEach ignores the returned promises
ids.forEach(async (id) => {
  await process(id);
});
console.log('done'); // runs before processing finishes

Use for...of for sequential, or Promise.all(ids.map(...)) for concurrent.

Returning a promise from inside a try/catch without awaiting it.

// Bug: the catch does not catch the rejection
try {
  return fetchData(); // not awaited
} catch (error) {
  // never runs
}

Mixing callbacks and promises. Wrapping a callback API in a promise is fine; using both styles in the same function is confusing.

Assuming await blocks. It suspends only the current async function.

When to use which

Use async/await when:

  • The logic is sequential and reads better top to bottom.
  • You need try/catch for error handling.
  • You are debugging and want readable stack traces.
  • The function has multiple awaits with dependencies between them.

Use promises directly when:

  • You are using a combinator: all, allSettled, race, any.
  • You are chaining a short transformation.
  • You are passing a promise into a library that expects one.
  • You want to start an operation now and handle it later.

In practice, most code uses both: async/await for the flow, Promise.all for concurrency.

Practical guidance

  • Default to async/await for readability.
  • Reach for Promise.all whenever operations are independent.
  • Always handle rejections — a catch or a try/catch, never neither.
  • Use allSettled when partial failure is acceptable.
  • Do not await inside forEach — it does not work.
  • Add timeouts to network calls; a promise that never settles hangs forever.
  • Prefer AbortController for cancellation rather than racing against a timeout promise.

For the underlying mechanism, see event loop explained and callbacks explained. For the API layer these usually wrap, rest api rate limiting and error handling patterns that actually work.

Quotable summary

A promise is an object representing a value that will exist later, with then, catch, and finally methods. async/await is syntax over promises that lets asynchronous code read like synchronous code, using try/catch for errors; an async function always returns a promise and await unwraps one. The two have identical performance, so the choice is about readability. The most important practical difference is concurrency: sequential awaits run one after another, while Promise.all runs them concurrently, often several times faster. Unhandled rejections terminate Node processes and are silently swallowed in browsers, so every promise chain needs a handler. Use async/await for flow and promises directly for the combinators all, allSettled, race, and any.

Frequently asked questions

What is the difference between a promise and async/await?
A promise is an object representing a future value, with then and catch methods. async/await is syntax built on promises that lets you write the same logic with try/catch and no callbacks. An async function always returns a promise.
Is async/await faster than promises?
No, they have the same performance because async/await compiles down to promises. What affects speed is whether you run operations sequentially or concurrently, not which syntax you use.
What does await actually do?
await pauses the async function until the promise settles, then returns its resolved value or throws its rejection. It does not block the whole program, only the current async function.
What is Promise.all used for?
Promise.all runs multiple promises concurrently and waits for all of them, returning an array of results. It rejects as soon as any promise rejects, which is why Promise.allSettled exists for cases where you want all outcomes.
Why do I get 'unhandled promise rejection'?
Because a promise rejected and nothing handled it. In Node this terminates the process by default; in browsers it logs a warning. Add a catch to every chain, or wrap awaits in try/catch.
Can I use await at the top level?
Yes, in ES modules and modern Node. Top-level await lets you await a promise directly in a module without wrapping it in an async function. It is not available in CommonJS.