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

145
Vistas
Does the for loop block when the iteration invokes an async function without await keyword? (the invoked async function has the await keyword)

In the below pseudocode, when the for loop executes each iteration, then will the for loop block at each iteration waiting for the response of the async fetch (because await is used within the myasyncfn? Or do I need to use await keyword as shown in the comment below?

async myasyncfn(url){
return await fetch(url..).response;
}

for each url in url_array:
   myasyncfn(url);    #await myasyncfn(url)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It will not wait for the async function to complete before continuing the loop; in that sense, it will block. However, that just means it iterates through all URLs in quick succession, firing many fetch requests, which will then all run in the background in parallel. Once the loop is done firing those, your thread is unblocked.

To illustrate:

async function foo(i) {
    await new Promise(resolve => setTimeout(resolve, 5000));
    console.log('Completed', i);
}

for (let i = 0; i < 10; i++) {
    foo(i);
    console.log('Fired', i);
}

console.log('Done firing all async functions, unblocking...');

about 4 years ago · Juan Pablo Isaza Denunciar
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