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

216
Views
Find which promises aren't resolving?

I have an array of promises promises = [p1,p2,p3] however, one or more aren't resolving and so Promise.all(promises) never finishes and just keeps waiting.

How can I console.log every time each individual promise resolves (perhaps with the array index) so that I can find the one(s) that aren't resolving?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You could loop over all promises and wait for each individual promise to resolve.

const p1 = new Promise(resolve => setTimeout(resolve, 1000, 'p1'));
const p2 = new Promise(resolve => setTimeout(resolve, 3000, 'p2'));
const p3 = new Promise(resolve => {/* never resolve */});

const promises = [p1, p2, p3];

promises.forEach((p, i) => {
  p.then((value) => {console.log('Promise at index %i resolved with %o', i, value);});
});

about 4 years ago · Santiago Gelvez 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!