title: How to prevent Bluebird’s Warning: a promise was created in a handler but was not returned from it
body: <p>So I have this code:</p>
  
  <pre><code>profileRepository.get(profileUuid).then((profile) =&gt; {
    if (profile.fileUuid) {
      profileStore.getFile(profile.fileUuid).then((fileData) =&gt; {
        data.fileData = fileData;
      }, callback);
    }
  
    data.profile = profile;
  }, callback);
  </code></pre>
  
  <p>and I am getting the warning:</p>
  
  <pre><code>Warning: a promise was created in a handler but was not returned from it
  </code></pre>
  
  <p>Which I believe is happening because <code>profileStore.getFile()</code> returns a promise too.  Now generally the way to get rid of that warning would be to chain the <code>then()</code>'s, doing something more like:</p>
  
  <pre><code>profileRepository.get(profileUuid).then((profile) =&gt; {
    if (profile.fileUuid) {
      return profileStore.getFile(profile.fileUuid);
    }
  
    data.profile = profile;
  }, callback)
  .then((fileData) =&gt; {
    data.fileData = fileData;
  }, callback);
  </code></pre>
  
  <p>The issue is that I have to call <code>profileStore.getFile()</code> conditionally so I don’t see how I can use then chaining in this case nor do I see a way to re-write this code in any other way to prevent the warning from happening.  I tried <code>return null</code> from the <code>get()</code> success callback but that does not even prevent the warning.</p>
  
  <p>The warning is just causing my console log to fill up which makes it really annoying when I need to do debugging and stuff, does any know of a way to prevent this warning with this use case?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have also tried this with the same warning:</p>
  
  <pre><code>profileRepository.get(profileUuid).then((profile) =&gt; {
    if (profile.fileUuid) {
      return profileStore.getFile(profile.fileUuid);
    }
  
    data.profile = profile;
  }, callback)
  .then((fileData) =&gt; {
    data.fileData = fileData;
  }, callback);
  </code></pre>