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

207
Views
Can I have multiple .finally() as well as multiple .catch() in Promise.all()?

var p1 = new Promise((resolve, reject) => {

        resolve('p1');
    });

    var p2 = new Promise((resolve, reject) => {
        resolve('p2');
    });
    Promise.all([
        p1.finally(() => { console.log("p1 completed"); }),
        p2.finally(() => { console.log("p2 completed"); }),
    ]).then(values => {
        console.log(values[0]);
        console.log(values[1]);
    }).finally(() => {
        console.log("all() completed");
  

I think I've only seen examples on the web with a single .finally() at the end [1]: https://i.stack.imgur.com/HeQV8.png

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Sure, finally is a chainable promise method just like catch (with the only difference that its callback does not take a parameter). You can use it as many times as you want, on any promise.

Promise.all([
    p1.finally(() => { console.log("p1 completed"); }),
    p2.finally(() => { console.log("p2 completed"); }),
]).finally(() => {
    console.log("all() completed");
})
about 4 years ago · Juan Pablo Isaza Report

0

You may chain as many .finally() calls as you like onto any promise.
(Promise.all() returns a new promise, so this rule applies here as well.)

Run this, and you should see all 3 comments log.

Promise.resolve().
  finally(() => console.log('Finally #1')).
  finally(() => console.log('Finally #2')).
  finally(() => console.log('Finally #3'))

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!