title: Promises: is .done() executed always even if .catch() is?
body: <h1>My Promise issue</h1>
  
  <p>I am new to <code>Promises</code> and I've been reading the <a href="https://github.com/kriskowal/q" rel="noreferrer">Q Documentation</a>, where it says:</p>
  
  <blockquote>
    <p>When you get to the end of a chain of promises, you should either return the last promise or end the chain.</p>
  </blockquote>
  
  <p>I have defined a Promise in my code the <code>Q.Promise</code> way, with the following <code>console.log</code>s to log out an execution trace:</p>
  
  <pre><code>function foo(){
     return Q.Promise(function(resolve, reject) {
  
      doSomething()
      .then(function() {
        console.log('1');
        return doSomething1();
      })
      .then(function() {
        console.log('2');
        return doSomething2();
      })
      .then(function() {
        console.log('3');
        return doSomething3();
      })
      .catch(function(err) {
        console.log('catch!!');
        reject(err);
      })
      .done(function() {
        console.log('done!!');
        resolve();
      });
  
    });
  }
  </code></pre>
  
  <p>In case every <code>doSomethingN()</code> executes correctly, everything works as intended and I get the expected trace:</p>
  
  <pre><code>1
  2
  3
  done!!
  </code></pre>
  
  <p><strong>But</strong> in case any of the <code>doSomethingN()</code> fails:</p>
  
  <p><code>foo()</code> works correctly, because the error function callback is the one that runs whenever a <code>reject(err)</code> occurs:</p>
  
  <p><code>foo().then(function() { /* */ }, function(err) { /* this runs! */ });</code></p>
  
  <p>And I get the following trace (ie. when <code>doSomething1()</code> fails):</p>
  
  <pre><code>1
  catch!!
  done!!
  </code></pre>
  
  <h2>My question</h2>
  
  <p>What I thought at first was the following:</p>
  
  <blockquote>
    <p>Okay, let's handle the chaining <strong>success</strong> and <strong>failure</strong> in both: <code>.done()</code> and <code>.catch()</code> methods. If everything goes well <code>.done()</code>'s callback will be executed and the promise will be <em>resolved</em>. In case there's an error at any point, <code>.catch()</code>'s callback will be executed and the promise will be <em>rejected</em> - and because of that, <code>done()</code> won't be executed.</p>
  </blockquote>
  
  <p>I think I am missing something about how the <code>.done()</code> works... because by having a look at my logging trace, I realized that <code>.done()</code> seems to be executing always - whether there is an error and <code>.catch()</code> is executed or not - and that is what I wasn't expecting.</p>
  
  <p>So, after that, I removed <code>.done()</code>'s callback and now <code>foo()</code>:</p>
  
  <ul>
  <li>works if there's an <code>error</code> during the chain execution</li>
  <li>does not work if everything works correctly</li>
  </ul>
  
  <p>What should I reconsider and how could/should I make it work?</p>