Node.js 蓝鸟和猫鼬:警告:在处理程序中创建了承诺,但没有从中返回

Node.js 蓝鸟和猫鼬:警告:在处理程序中创建了承诺,但没有从中返回,node.js,mongodb,mongoose,bluebird,Node.js,Mongodb,Mongoose,Bluebird,我在项目中使用猫鼬和蓝知更鸟。即使我更正了所有代码,这个警告也无处不在。它仍然在发生 exports.middleware = function (req, res, next, id) { Account.findById(id).exec().then(function(account) { if (!account) { return res.status(404).send({ message: 'No account with that iden

我在项目中使用猫鼬和蓝知更鸟。即使我更正了所有代码,这个警告也无处不在。它仍然在发生

exports.middleware = function (req, res, next, id) {
  Account.findById(id).exec().then(function(account) {
    if (!account) {
      return res.status(404).send({
        message: 'No account with that identifier has been found'
      });
    }
    req.account = account;
    next();
  }).catch(function(err) {
    return next(err);
  });
};

在检查lib/query.js的mongoose源代码后,我注意到exec()回调函数中存在一些问题


承诺是没有回报的。然后()。所以在猫鼬解决这个问题之前。我只是避免在代码中使用exec(回调)。然后每个人都会很高兴。

此警告已在3.4.3中更新,更有帮助。它现在似乎已修复,在下一版本的mongoose中应该可以使用
query.prototype.exec = function exec(op, callback) {
  ...
  if (callback) {
    promise.then(
      function() {
        callback.apply(null, _results);
      },
      function(error) {
        callback(error);
      });
  }
  ...
}