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

239
Views
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 answers
Answer question

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 Report
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!