Closed emirotin closed 8 years ago
I assume you're using jade because you mention using locals
? Just from this output it is difficult to see whether this is a bug in metalsmith-layouts, or a configuration error.
If you could create a reduced test case that would help in troubleshooting this.
I use swig. Thanks, I will try to repro it.
So it's actually simple.
Create any recursive object:
nav = {
title: "root",
children: [ { title: "child" } ]
}
nav.children[0].parent = nav
Then pass locals: { nav: nav }
When you call var clonedParams = extend(true, {}, params);
it goes into infinite recursion.
Hi @emirotin, what I meant with reduced test case was a repo that replicates the problem in the most minimal way possible. It is difficult for me to judge what's going on from code snippets, I need to see your entire config.
I already reduced it to the specific line of code in your module (var clonedParams = extend(true, {}, params);
is taken straight from index.js
). It's already minimal because it's isolated from the rest of params, template language, and everything.
And I also explained what happens there: the module you use for deep objects cloning (extend
) can't deal with circular refs.
You're giving me the problem, but not a complete example of the use case that leads to that problem. If you want me to take a look at it I'll need the complete picture.
I'll close this for now. Feel free to point me at an example repo if you have one and I'll be happy to take a look. Otherwise I'll see if I can dive into this when I have the time.
I have an object (navigation tree, with parent -> children -> child -> parent references) passed to
locals
. It causes building failing with what's most likely a call stack overflow. The stack looks likeConfirmed by removing backlinks (not a huge deal because of that).