Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda