SystemStackError when trying to rebuild a tree with depth of 500.
If you've got a hierarchy with a depth of around 500 you can't rebuild! the tree without it resulting in a SystemStackError: stack level too deep.
Here's a test that illustrates the failure. I don't have a patch or workaround, but wanted to report it.
it 'rebuilds deeply nested tree' do
parent = nil
500.times do |counter|
parent = Metal.create(:value => "Nitro-#{counter}", parent: parent)
end
expect { Metal.rebuild! }.not_to raise_error
end
@phallstrom that's the Ruby limit to ensure you don't have an infinite loop.
A quick Google search to increase the Ruby stack depth reveals this post on Stack Overflow: https://stackoverflow.com/questions/242617/how-to-increase-stack-size-for-a-ruby-app-recursive-app-getting-stack-level-to
Look at RUBY_THREAD_VM_STACK_SIZE and some of the other more recent posts for Ruby 2.0+
@joelvh Agreed. I should have included that. Wanted to report the issue as in case others come across it and/or want to rewrite the code so it doesn't recurse and avoid the issue entirely.
maybe we can write this into README.md and close this issue