atom-gitbook icon indicating copy to clipboard operation
atom-gitbook copied to clipboard

Cyclical {% include %} causes crash

Open cthos opened this issue 10 years ago • 5 comments

Say I have 2 markdown files: md1.md and md2.md.

md1.md contains

# My Cool header

{% include md2.md %}

and md2.md contains

# I just want to watch the world burn.

{% include md1.md %}

This situation creates an infinite loop and crashes the editor.

cthos avatar Oct 14 '15 20:10 cthos

This appears to put gitbook itself into an infinite loop.

CashWilliams avatar Oct 14 '15 21:10 CashWilliams

Ah, no it actually dies eventually with RangeError: Maximum call stack size exceeded (In file "[file name]")

CashWilliams avatar Oct 14 '15 21:10 CashWilliams

Either way you don't want Atom to crash when this happens. So maybe detect the cyclical loop and toss up a warning?

cthos avatar Oct 14 '15 21:10 cthos

So maybe just a recursion counter? With a max depth of something like 10?

CashWilliams avatar Oct 14 '15 21:10 CashWilliams

That sounds reasonable to me, yeah.

cthos avatar Oct 14 '15 21:10 cthos