title: Bluebird warning "A promise was created in a handler but was not returned from it"
body: <p>I get the warning about not returning a created promise from Bluebird and I do not understand why and how I should rewrite my code. </p>
  
  <p>(I have tried reading about the warning at <a href="https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md#warning-a-promise-was-created-in-a-handler-but-none-were-returned-from-it" rel="noreferrer">Bluebird API</a> page and the <a href="https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns" rel="noreferrer">anti-pattern page</a> as I suspect this is what I'm doing)</p>
  
  <p>In my view.js file:</p>
  
  <pre><code>var express = require('express'),
      router = express.Router(),
      settings = myReq('config/settings'),
      Sets = myReq('lib/Sets'),
      log = myReq('lib/utils').getLogger('View');
  
  router.get('/:setId/', function(req, res, next) {
      var
          setId = req.params.setId,  
          user = req.user,
          set = new Sets(setId, user);
  
      log.info('Got a request for set: ' + setId);
  
      // The below line gives the warning mentioned
      set.getSet().then(function(output) {
          res.send(output);
  
      }).error(function(e){
          log.error(e.message, e.data);
          res.send('An error occurred while handling set:' + e.message);
      });
  
  });
  
  module.exports = router;
  </code></pre>
  
  <p>In my Sets.js file I have:</p>
  
  <pre><code>var
      Promise = require('bluebird'),
      OE = Promise.OperationalError,
      settings = myReq('config/settings'),
      UserData = myReq('lib/userData'),
      log = myReq('lib/utils').getLogger('sets'),
      errorToSend = false;
  
  module.exports = function(setId, user) {
      var 
          sets = myReq('lib/utils').getDb('sets');
  
      return {
  
          getSet : function() {
  
              log.debug('Getting set')
  
              return sets.findOneAsync({
                  setId:setId
              }).then(function(set){
                  if ( set ) {
                      log.debug('got set from DB');
                  } else {
                      set = getStaticSet(setId);
                      if ( ! set ) {
                          throw new OE('Failed getting db records or static template for set: ' + setId );
                      }
                      log.debug('got static set');
                  }
  
                  log.debug('I am handling set')
  
                  if ( ! checkSet(set) ) {
                      var e = new OE('Failed checking set');
                      e.data = set;
                      throw e;
                  }
  
                  return {
                      view : getView(set),
                      logic : set.logic,
                      canEdit : true,
                      error : errorToSend
                  };
  
              });
          }
      };
  };
  </code></pre>
  
  <p>So the line in my view.js file with "set.getSet()" gives the warning about not returning the created promise. It seems like this script still does what I expect it to do, but I do not understand why I get the warning.</p>
  
  <p>Stacktrace:</p>
  
  <pre><code>Warning: a promise was created in a handler but was not returned from it
      at Object.getSet (C:\dev\infoscrn\lib\Sets.js:36:25)
      at C:\dev\infoscrn\routes\view.js:39:20
      at Layer.handle [as handle_request] (C:\dev\infoscrn\node_modules\express\lib\router\layer.js:82:5)
      at next (C:\dev\infoscrn\node_modules\express\lib\router\route.js:110:13)
      at Route.dispatch (C:\dev\infoscrn\node_modules\express\lib\router\route.js:91:3)
      at Layer.handle [as handle_request] (C:\dev\infoscrn\node_modules\express\lib\router\layer.js:82:5)
      at C:\dev\infoscrn\node_modules\express\lib\router\index.js:267:22
      at param (C:\dev\infoscrn\node_modules\express\lib\router\index.js:340:14)
      at param (C:\dev\infoscrn\node_modules\express\lib\router\index.js:356:14)
      at Function.proto.process_params (C:\dev\infoscrn\node_modules\express\lib\router\index.js:400:3)
      at next (C:\dev\infoscrn\node_modules\express\lib\router\index.js:261:10)
      at Function.proto.handle (C:\dev\infoscrn\node_modules\express\lib\router\index.js:166:3)
      at router (C:\dev\infoscrn\node_modules\express\lib\router\index.js:35:12)
      at Layer.handle [as handle_request] (C:\dev\infoscrn\node_modules\express\lib\router\layer.js:82:5)
      at trim_prefix (C:\dev\infoscrn\node_modules\express\lib\router\index.js:302:13)
      at C:\dev\infoscrn\node_modules\express\lib\router\index.js:270:7
      at Function.proto.process_params (C:\dev\infoscrn\node_modules\express\lib\router\index.js:321:12)
      at next (C:\dev\infoscrn\node_modules\express\lib\router\index.js:261:10)
      at C:\dev\infoscrn\node_modules\express\lib\router\index.js:603:15
      at next (C:\dev\infoscrn\node_modules\express\lib\router\index.js:246:14)
  </code></pre>