node.js - nodejs堆栈溢出怎么解决?
怪我咯
怪我咯 2017-04-17 11:39:33
0
1
552

突然就提示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
            });
        }
    });
});

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
洪涛

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template