我的错误日志中出现以下错误。我不知道它何时发生,无法跟踪问题,因为它没有显示我的代码,而是显示node_module(mongoose)。如果您将想法发送到调试和修复,那将会很棒。
当我用Google搜索时,我发现它是在递归调用异步函数时发生的。但我没有通过异步调用进行任何递归调用或循环。
谢谢, Thavaprakash。 S上。
RangeError: Maximum call stack size exceeded
at Promise.emit (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
at Promise.fulfill (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
at Promise.<anonymous> (/home/ubuntu/myproject/node_modules/mongoose/lib/model.js:1544:35)
at Promise.<anonymous> (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
at Promise.emit (events.js:110:17)
at Promise.emit (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
at Promise.fulfill (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
at handleSave (/home/ubuntu/myproject/node_modules/mongoose/lib/model.js:133:13)
at /home/ubuntu/myproject/node_modules/mongoose/lib/utils.js:408:16
at /home/ubuntu/myproject/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection/core.js:128:9
at /home/ubuntu/myproject/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1195:7
at /home/ubuntu/myproject/node_modules/mongoose/node_modules/mongodb/lib/mongodb/db.js:1903:9
at Server.Base._callHandler (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)
at /home/ubuntu/myproject/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:487:18
at MongoReply.parseBody (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at null.<anonymous> (/home/ubuntu/myproject/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:445:20)
更新
请查看以下示例代码。
var Promise = require('bluebird');
var Business = require('business.model');
var User = require('user.model');
var userPromise = User.findOne({userId:121454}, function (err, user) {}).exec();
Promise.all([userPromise]).then(function(results){ // here one promise passed, we may pass multiple promise in future
var user = results[0];
Business.findOne({bid:user.businessId},{}, function (err, busin) {
if(err){
console.log(err);
res.status(500);
return res.json({"code":500,"error": "internal server error"})
}
res.status(200);
return res.json({"name": busin.name})
});
});
答案 0 :(得分:0)
我收到了以下链接的回复。感谢VKarpov
https://github.com/Automattic/mongoose/issues/3582#issuecomment-158436688
谢谢,Thavaprakash。 S上。