{"action":"closed","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/3570","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/3570/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/3570/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/3570/events","html_url":"https://github.com/Automattic/mongoose/issues/3570","id":116521581,"number":3570,"title":"Bluebird 3.0.5 Promises : warning about handler not returning a promise","user":{"login":"BenjaminBini","id":1637397,"avatar_url":"https://avatars.githubusercontent.com/u/1637397?v=3","gravatar_id":"","url":"https://api.github.com/users/BenjaminBini","html_url":"https://github.com/BenjaminBini","followers_url":"https://api.github.com/users/BenjaminBini/followers","following_url":"https://api.github.com/users/BenjaminBini/following{/other_user}","gists_url":"https://api.github.com/users/BenjaminBini/gists{/gist_id}","starred_url":"https://api.github.com/users/BenjaminBini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenjaminBini/subscriptions","organizations_url":"https://api.github.com/users/BenjaminBini/orgs","repos_url":"https://api.github.com/users/BenjaminBini/repos","events_url":"https://api.github.com/users/BenjaminBini/events{/privacy}","received_events_url":"https://api.github.com/users/BenjaminBini/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/mongoose/labels/can't%20reproduce","name":"can't reproduce","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Automattic/mongoose/milestones/71","html_url":"https://github.com/Automattic/mongoose/milestones/4.2.6","labels_url":"https://api.github.com/repos/Automattic/mongoose/milestones/71/labels","id":1402965,"number":71,"title":"4.2.6","description":"","creator":{"login":"vkarpov15","id":1620265,"avatar_url":"https://avatars.githubusercontent.com/u/1620265?v=3","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":5,"state":"open","created_at":"2015-11-09T20:11:04Z","updated_at":"2015-11-13T16:09:52Z","due_on":"2015-11-16T05:00:00Z","closed_at":null},"comments":2,"created_at":"2015-11-12T10:30:17Z","updated_at":"2015-11-13T16:09:52Z","closed_at":"2015-11-13T16:09:52Z","body":"Hi,\r\n\r\nI use bluebird promises with Mongoose (by setting `mongoose.Promise = require('bluebird')`) and since the last version of bluebird (3.0.5) [a new warning](http://bluebirdjs.com/docs/warning-explanations.html#warning-a-promise-was-created-in-a-handler-but-none-were-returned-from-it) is triggered when a Promise is created in a handler but nothing is returned from it : \r\n\r\n``` bash\r\nWarning: a promise was created in a  handler but was not returned from it\r\n    at Query.exec (C:\\benjamin\\dil\\node_modules\\mongoose\\lib\\query.js:2125:10)\r\n    at Query.then (C:\\benjamin\\dil\\node_modules\\mongoose\\lib\\query.js:2155:15)\r\n    at model._hasBeenAnswered (C:\\benjamin\\dil\\server\\models\\question.model.js:47:6)\r\n```\r\n\r\nThe corresponding lines :\r\n\r\n```javascript\r\nQuery.prototype.exec = function exec(op, callback) {\r\n  var Promise = PromiseProvider.get();\r\n  var _this = this;\r\n\r\n  if ('function' == typeof op) {\r\n    callback = op;\r\n    op = null;\r\n  } else if ('string' == typeof op) {\r\n    this.op = op;\r\n  }\r\n\r\n  return new Promise.ES6(function(resolve, reject) { // 2125\r\n    if (!_this.op) {\r\n      callback && callback(null, undefined);\r\n      resolve();\r\n      return;\r\n    }\r\n\r\n    _this[_this.op].call(_this, function(error, res) {\r\n      if (error) {\r\n        callback && callback(error);\r\n        reject(error);\r\n        return;\r\n      }\r\n      callback && callback.apply(null, arguments);\r\n      resolve(res);\r\n    });\r\n  });\r\n};\r\n\r\n/**\r\n * Executes the query returning a `Promise` which will be\r\n * resolved with either the doc(s) or rejected with the error.\r\n *\r\n * @param {Function} [resolve]\r\n * @param {Function} [reject]\r\n * @return {Promise}\r\n * @api public\r\n */\r\n\r\nQuery.prototype.then = function(resolve, reject) {\r\n  return this.exec().then(resolve, reject); // 2155\r\n}\r\n```\r\n\r\nThe line from my code is this one : \r\n\r\n```javascript\r\nreturn User.find({username: username})\r\n    .then(....\r\n```"}}