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

228
Vistas
Avoid await in do..while() with chain dependancies

Here is the situation:

I am calling the following function which compute a large set of Elastic Data (the buckets variable is the set of documents)

    await this.computeAllData(start, range, wait, buckets, accumulator);

Here is the code inside the previous function:

  async computeAllData(start, range, wait, buckets, accumulator) {
    let nextAfter = false;
    do { 
      nextAfter = await this.computeOne(
        start,
        range,
        wait,
        buckets,
        accumulator,
        nextAfter
      );
    } while (nextAfter);
  }

The problem is : I should not use "await" inside a loop (ESLint rules). But I can find a way to keep the behavior of the do...while()(stop the loop when data were digest) with the async/await approach.

I try with yield/generator approach but it's a failure, too complex for me :(

Please any idea ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No, that ESLint rule is stupid. It should be a warning to suggest that maybe you could run the asynchronous actions concurrently. But no, you absolutely cannot in your case, you want your processing to be sequential. Ignore the rule or disable it altogether.

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