RangeError: Maximum call stack size exceeded
victorjussiani opened this issue · 4 comments
victorjussiani commented
Hello guys, I`m having one problem and i dont know what is it..
I`m using mongoose to fetch an array of posts to render my page.
loadPost : function *() {
var posts = yield Post.find({url: this.params.post}).exec();
yield this.render('blog/index', {
'posts' : posts
});
}
But, when i execute this code occurred this error
RangeError: Maximum call stack size exceeded
at String.match (native)
at typeOf (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:67:36)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:39:11)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:57:21)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:57:21)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:49:21)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:57:21)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:57:21)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:49:21)
at clone (/Users/victorjussiani/Developer/Node.js/kaizen-website/node_modules/koa-hbs/node_modules/merge/merge.js:57:21)
Sorry for my english, if someone can help me =D
jwilm commented
It appears posts
is a mongoose document which could potentially be a recursive data structure. In your call to render
, try calling toObject()
on posts
. The code would look like below.
yield this.render('blog/index', {
'posts': posts.toObject()
});
jwilm commented
I just pushed a patch to npm that should handle recursive objects. Please try updating and let me know how it goes. You won't need the toObject()
after updating.
jwilm commented
Is this fixed for you?
victorjussiani commented
I apologize for the delay. Worked perfectly, thank you very much = D