Skip to the page

Async & event loop · Concept

async/await semantics and error handling

The interviewer asks

What does async/await compile down to conceptually? How do you handle errors, run things in parallel, and avoid accidental waterfalls?

Then

Follow-ups the interviewer asks next

  1. await in a for loop vs Promise.all(items.map(...)). When is sequential correct?
  2. What happens to an unhandled rejection in the browser vs Node?
  3. return promise vs return await promise inside try/catch (see Output section).
  4. Top-level await in ESM and its effect on module loading.

The answer

What a strong answer covers

  • An async function always returns a promise; await suspends and resumes in a microtask
  • try/catch around awaits; .catch on the returned promise; Promise.allSettled for partial failure
  • Start promises first, then await them, to parallelise
  • Unhandled rejections: the unhandledrejection event in browsers; recent Node versions crash the process by default

The red pen

Common traps

Avoid:"await blocks the thread"; wrapping everything in one try/catch and swallowing errors.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview