search

Home  >  Q&A  >  body text

node.js - nodejs堆栈溢出怎么解决?

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

怪我咯怪我咯2777 days ago548

reply all(1)I'll reply

  • PHP中文网

    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

    reply
    0
  • Cancelreply