跪拜 Guibai
← All articles
JavaScript · Promise · ECMAScript 6

async/await vs Promise: The Difference Is Error Flow, Not Syntax

By htzyl206 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Misusing async/await leads to silent error swallowing, runaway pending Promises, and order-of-magnitude performance gaps that are easy to miss in code review. These tested facts give Node and browser developers a precise, environment-validated boundary for when try/catch works and when it doesn't, plus a clear rule for mixing combinators with await in real code.

Summary

A deep, environment-tested breakdown of when to use async/await versus Promise combinators. The article makes the case that these aren't competing technologies, but two ways of writing the same thing: async functions always return a Promise, and await is just sugar over .then. The choice comes down to intent — linear flows get async/await, concurrent waits get Promise.all and friends.

The core advantage of async/await is error handling that flows naturally through control flow. But the article's measurements, run identically on Node 22.22.2, 24.22.3, 26.13.1 and Chrome 152, show a narrow boundary: try/catch only catches errors thrown on the current synchronous chain. Errors inside timers or other Promise callbacks are untouchable, and an executor that throws inside setTimeout leaves a Promise pending forever.

Several practical pitfalls are documented with measured ordering: await resumes via a microtask continuation, not in place; return and return await produce different finally ordering; forEach discards async callback promises; and three serial awaits are three times slower than Promise.all. The article closes with a decision table, a quick reference card, and six concrete mistakes to avoid, including the need for AbortController when cancellation matters.

Takeaways
— async functions always return a Promise, even when returning a plain value; await on a non-Promise wraps it with Promise.resolve.
— try/catch only catches errors thrown on the current synchronous execution chain; errors inside timers, event callbacks, or other Promise callbacks are invisible to it.
— A Promise whose executor throws inside setTimeout never settles, so await on it hangs forever; measured as pending-forever across all four tested environments.
— return somePromise in an async function doesn't wait for the Promise inside try/finally; the finally cleanup runs before the Promise settles, unlike return await.
— forEach with an async callback discards the returned Promises, leaving you unable to await them; use map + Promise.all instead.
— Three serial awaits with 100ms each took about 320ms compared to about 105ms for Promise.all, a three-time slowdown attributed to serialization, not to await itself.
— Promise.all doesn't cancel losing requests; both it and Promise.race leave losers running, and AbortController is the only way to truly cancel.
— Promise.race([]) never settles because an empty array has no Promise to trigger the race.
— An async function without any await runs synchronously from the start; a thrown error becomes an unhandled rejection because nobody attaches a catch.
— The decision rule: use async/await when you need try/catch, use combinators for concurrent waits; mixing both in a single function is standard practice.
Conclusions

Framing async/await as 'sugar' shifts the real question from syntax to error semantics: the only meaningful change is that errors become control flow rather than values passed through callbacks.

The measured boundary of try/catch explains why 'unhandled rejection' events exist at all: a synchronous try/catch can't see errors that escape into timers or other callbacks, so the host needs its own channel for them.

The return vs return await ordering difference shows how easily a piece of syntax can change observable behavior in a way that's invisible without an execution-order test; this is the kind of subtlety that makes async code hard to reason about.

The three-times-slower benchmark makes a practical point beyond performance: consecutive awaits encode a serial dependency that readers can't see unless they inspect the code; Promise.all expresses concurrency explicitly, which matters for maintainability as much as speed.

The article's hard rule against async callbacks in forEach reflects a broader principle: any API that discards return values silently becomes a trap when those returns are Promises, and the fix isn't to add await but to switch to a combinator.

Concepts & terms
Continuation
In the context of await, a continuation is the function that packages the code after an await point; it gets scheduled into the microtask queue, determining that execution resumes on the next microtask round rather than immediately.
Promise combinator
A method like Promise.all, Promise.any, Promise.race, or Promise.allSettled that takes an array of Promises and returns a single Promise that settles based on the group's behavior, letting you express different concurrency intents.
Unhandled rejection
A Promise rejection that has no catch handler attached; it surfaces through host-specific events (like Node's unhandledRejection) and is distinct from a synchronous error that try/catch can manage.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗