I ran into this issue when trying to render a template that iterated over a very large array. I think the same issue exists with very large objects or a very large amount of simple tags. This commit would fix that too.
Also, I'm open to suggestions how to make this look less like a hack. :-)
Test and fix for stack overflow when rendering very large arrays
Add check to prevent the stack from overflowing. Fix #43.
Thanks for the the bug report and knocking this out. I ended up rewriting the code a bit, but used your tests. The process.nextTick on every iteration hurt performance pretty badly (you can run test/bench.js for a bad benchmark, but decent baseline).