spree_braintree_vzero
spree_braintree_vzero copied to clipboard
SystemStackError (stack level too deep) - Issue with Braintree in production
Hey all.
I've not been able to have any success getting the Braintree v.zero gem to work in production without producing the following stack error.
I, [2016-08-09T02:38:57.067355 #21275] INFO -- : Rendered /apps/edgelit-gallery/shared/bundle/ruby/2.3.0/gems/spree_backend-3.1.0/app/views/spree/admin/shared/_main_menu.html.erb (2.2ms)
I, [2016-08-09T02:38:57.067561 #21275] INFO -- : Completed 500 Internal Server Error in 92ms (ActiveRecord: 3.0ms)
F, [2016-08-09T02:38:57.128941 #21275] FATAL -- :
SystemStackError (stack level too deep):
/apps/edgelit-gallery/shared/bundle/ruby/2.3.0/bundler/gems/spree_braintree_vzero-a6b3fa637387/app/helpers/spree/admin/navigation_helper_decorator.rb:6:in `link_to_with_icon'
/apps/edgelit-gallery/shared/bundle/ruby/2.3.0/gems/spree_backend-3.1.0/app/helpers/spree/admin/navigation_helper.rb:35:in `tab'
/apps/edgelit-gallery/shared/bundle/ruby/2.3.0/gems/spree_backend-3.1.0/app/views/spree/admin/shared/_main_menu.html.erb:3:in `_5aa8906de7ed3f1abc19bb8b99923123'
/apps/edgelit-gallery/shared/bundle/ruby/2.3.0/gems/spree_backend-3.1.0/app/views/spree/layouts/admin.html.erb:34:in `_1dae9f5fadea745b1b7ba9042d8797f1'
This is a fresh un-altered version of spree 3.1.0 and the corrosponding 3-1-stable Braintree v.zero gem, running with rails 4.2.6.
It's only an issue in production (runs fine in development), and I just can't understand what's going on, I wonder if there's something wrong with this particular version, or if there's something else I'm missing.
The app is running via nginx + passenger, with ruby 2.3.1p112.
Any ideas?
Are you by any chance deploying with something like mina or capistrano? I'd guess so from the shared
folder in your stack trace.
I ran into the same issue yesterday and spent some time debugging it. The issue is that the decorators are being loaded twice, meaning the alias here ends up aliasing itself rather than the original method: https://github.com/spree-contrib/spree_braintree_vzero/blob/3-1-stable/app/helpers/spree/admin/navigation_helper_decorator.rb#L2
The first time is from the to_prepare
callback here: https://github.com/spree-contrib/spree_braintree_vzero/blob/3-1-stable/lib/spree_braintree_vzero/engine.rb#L12-L16
The second time is from rails' eager loading. This means that the file gets required with two different paths. In my case:
/opt/project-name/current/vendor/bundle/ruby/2.3.0/bundler/gems/spree_braintree_vzero-a6b3fa637387/lib/spree_braintree_vzero/../../app/helpers/spree/admin/navigation_helper_decorator.rb
/opt/project-name/shared/bundle/ruby/2.3.0/bundler/gems/spree_braintree_vzero-a6b3fa637387/app/helpers/spree/admin/navigation_helper_decorator.rb
Because one is from the symlinked directory and one is from the real location it get's required twice. As a workaround for this I created a fork which normalizes the path before loading it: https://github.com/builtbybuffalo/spree_braintree_vzero/commit/dabc805772e17471927d40612195c7745f2f9736. That's working well for us now but I'm not sure how "correct" the fix is. A more appropriate solution may be to figure out why the paths are differing in the first place.
@charlie-hadden Yea using Mina. After getting a couple of other people to look at it we determined much the same thing. Just couldn't figure out why it gets required twice, or what the nice solution would be, if there even is one. Seems like it should really support deployments via Mina or Cap, but I suppose lots of people just use Heroku?
Is there any update regarding this bug? I am getting same one and above patch is also not working.