突然就提示Maximum call stack size exceeded了
控制台:
bbs.js : 1
bbs_a: 2
bbs.js : 2
bbs_a: 2
invoked[readComment]
bbs.js :4
GET /bbs 500 1368.168 ms - 64
router.get('/', function(req, res) {
console.log("bbs.js : 1");
var comment = new Bbs();
console.log("bbs.js : 2");
comment.readComment(function(err, result) {
if (err) {
console.log("bbs.js :3");
res.status(404).end(err);
} else {
console.log("bbs.js :4");
res.render('bbs', {
items: result
});
}
});
});
PHP中文网2017-04-17 11:41:33
You can add a setTimeout(func, 0) when calling the function. This is not a direct recursive function, but placed in the nodejs event response queue