Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Why is the async function execution executed synchronously

enter image description here enter image description here

const c = async() => console.log("2")
const a = async() => {
  console.log("1")
  await c()
  console.log("4")
}
const b = () => console.log("3");
console.log("start")
a();
b();

I would expect the sequence here to be 3 1 4 2, but apparently it is not. Async function seem to execute synchronously and be added to the callstack UNTIL they return, and that is when the rest is added to the event queue. Why is that and why is it not instantly added to the event queue?

Link to ECMA spec & other reads also greatly appreciated

This seem to explain why 1 is printed first, but not why the 2 is printed second, since by that answer it should return a promise on the FIRST await, but it actually executes b synchronously: When does async function actually return a pending promise?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!