JavaScript async/await under the hood
async functions always return promises; await pauses the function until that promise settles.
Published here , updated · 4 sources · Resume reading
async/await is syntax for promises, not a second runtime [1] [2]. An async function always returns a Promise; await suspends that function until the awaited promise fulfills or rejects [1]. Read this after JavaScript promises and the event loop. Parallelism language: concurrency vs parallelism.
Quick start (under a minute)
node -e "async function f(){return 1;} console.log(f() instanceof Promise); f().then(v=>console.log(v));"You should see true then 1: the async function handed the caller a Promise, not the raw number.
Worked example on this draft host
MDN states that async functions always return promises and that await pauses the async function body [1]. The snippet below contrasts sequential awaits with Promise.all on two independent delays.
Observed on this draft host (Node.js v22.23.5, Linux, 2026-12-03):
foo() instanceof Promise true
foo().then value 1
parallel A B ms 50
sequential A B ms 101The sequential path waited about twice the single delay because each await finished before the next timer started. The parallel path started both timers first, so total wall time stayed near one delay. Your millisecond numbers will jitter; the ratio is what matters for teaching.
Program used:
async function slow(ms, label) {
await new Promise((r) => setTimeout(r, ms));
return label;
}
async function foo() {
return 1;
}
console.log("foo() instanceof Promise", foo() instanceof Promise);
foo().then((v) => console.log("foo().then value", v));
(async () => {
const t0 = Date.now();
const a = await slow(50, "A");
const b = await slow(50, "B");
console.log("sequential", a, b, "ms", Date.now() - t0);
})();
(async () => {
const t0 = Date.now();
const pa = slow(50, "A");
const pb = slow(50, "B");
const [a, b] = await Promise.all([pa, pb]);
console.log("parallel", a, b, "ms", Date.now() - t0);
})();Run with node async_timing_demo.js after saving the file.
See control flow as promise chaining
MDN: code before the first await runs synchronously; after each await, the remainder behaves like code inside a .then callback [1] [2]. That picture is why a missing await on an inner async call returns a pending Promise instead of the value you expected.
Implicit Promise wrapper
MDN documents that returning a non-promise value from an async function wraps it as if with Promise.resolve [1]:
async function foo() {
return 1;
}
function fooPromise() {
return Promise.resolve(1);
}Callers of foo() must treat the result as asynchronous even when the body looks synchronous. Logging properties on the return value without awaiting is a common beginner bug [2].
Walk a fetch with await
MDN Learn rewrites promise chains with try/catch around awaits [2]:
async function fetchProducts() {
try {
const response = await fetch(
"https://mdn.github.io/learning-area/javascript/apis/fetching-data/can-store/products.json",
);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const data = await response.json();
console.log(data[0].name);
} catch (error) {
console.error(`Could not get products: ${error}`);
}
}
fetchProducts();That block matches MDN Learn's async/await rewrite of the products fetch (accessed 2026-12-03), including try/catch around awaits [2].
Prefer Promise.all when work is independent
If you await task A completely before starting task B, B cannot overlap A even when they do not depend on each other [1]. Start both promises, store the returned promises in variables, then await Promise.all([...]) when you only need both results together [1] [2].
Sequential awaits remain correct when each step needs the previous result: authenticate, then fetch a user-specific URL, then parse JSON. The timing demo above is the minimal proof for independent delays.
Keep errors visible
A rejected promise at an await throws inside the async function [1]. Wrap risky awaits in try/catch, or attach .catch on the promise returned by the async function, so failures become visible instead of unhandled rejections [2].
async function mayFail() {
try {
return await Promise.reject(new Error("nope"));
} catch (err) {
return "recovered";
}
}Bare await outside an async function or ES module top level is a syntax error [1]. Top-level await in modules changes load order; treat that as a separate module-system topic from this page.
Trace microtasks with a tiny script
Promises settled by await schedule microtasks. Pair with JavaScript promises and the event loop when you need queue order drawn step by step.
async function loadName() {
const response = await fetch(
"https://mdn.github.io/learning-area/javascript/apis/fetching-data/can-store/products.json",
);
const data = await response.json();
return data[0].name;
}
console.log("sync start");
loadName()
.then((name) => console.log("then name", name))
.catch((e) => console.error(e));
console.log("sync end");You should see sync start, then sync end, then then name with the fetched string when the request succeeds [2]. The middle lines prove the async function returned a pending Promise immediately.
Relation to the event loop posts
Promises schedule microtasks. await is how you write microtask-heavy code without chaining .then manually [1] [2]. It does not move CPU work to another thread. Heavy computation still blocks the loop unless you offload to workers or native addons. Pair this page with JavaScript promises and the event loop for queue order and with concurrency vs parallelism when someone says "async is parallel."
Top-level await in modules
ES modules may use await at the top level when the bundler or runtime supports module async evaluation [1]. That changes load order: importers wait for the module graph to settle before running. It is useful for config loaders, not a replacement for lazy initialization in libraries consumed by both Node and browsers.
Library authors sometimes expose both sync and async APIs for the same resource. Document which path returns a Promise so callers do not double-await. TypeScript's Promise<T> return type helps static checks catch those mistakes before runtime.
Promise.allSettled waits for every promise without failing fast when one rejects [2]. That pattern fits bulk health checks. Promise.race returns the first settled result, useful for timeouts implemented as competing promises.
What suspension actually saves
When an async function hits await, the runtime stores the remaining bytecode or generator-like state for that function and returns a Promise to the caller [1]. Locals stay on that suspended activation; they are not copied into a worker thread. That is why a tight for loop of pure math after await still blocks painting: the continuation runs on the same event-loop turn once the Promise resolves [1] [2].
Cancellation is not built into bare await. You pass an AbortSignal into fetch, or you race a timeout Promise, or you check a flag after each await. Without that, a navigated-away page can still finish network work and touch dead DOM unless you guard the continuation.
Debugging tip: in Chromium DevTools, async stack traces stitch the await sites together so a rejection shows the caller that started the chain, not only the microtask that threw [2]. Enable async stacks when a .then chain looks like it came from nowhere.
Failure modes worth naming
Writing async on every function "for performance." Async adds promise wrapping overhead. Use it when the function actually awaits asynchronous work.
Forgetting await on an inner async call and getting a Promise where you wanted a value.
Awaiting independent network calls in series and blaming the API for latency.
async/await catches errors automatically. You still need try/catch or .catch.
Treating returned promises like plain objects (result.foo without await).
await freezes the entire runtime. It only suspends the current async function until its promise settles [1].
Rewrite one sequential fetch chain with Promise.all on two URLs that do not depend on each other, log Date.now() deltas, and keep the slower style only where step two truly needs step one's JSON. That one measurement ends more debates than another slide on microtasks.
Send this to the friend who thinks await moves work onto another CPU core.

Keep this guide
Filed under Dev explainers, Science
Questions about this guide
Does async make JavaScript multi-threaded?
No. MDN describes async/await as syntax over promises on a single-threaded event loop. Worker threads exist, but async alone does not spawn them.
What does an async function return?
Always a Promise. A plain return value is wrapped. Callers must await or chain .then.
Where can I use await?
Inside async functions, or at module top level in ES modules. Bare await elsewhere is a SyntaxError.
Should I await two independent delays one after another?
Only when the second depends on the first. Otherwise start both promises, then await Promise.all.
Does await block the whole program?
It suspends the current async function until the promise settles. Other timers and I/O callbacks can still run on the event loop.
Sources
- MDN: async function, accessed 2026-12-03developer.mozilla.org
- MDN Learn: How to use promises (async and await section), accessed 2026-12-03developer.mozilla.org
- Full Byte Developer: JavaScript promises and the event loopfullbytedeveloper.com
- Full Byte Developer: Concurrency vs parallelismfullbytedeveloper.com