Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda