Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemStackError (stack level too deep) - Issue with Braintree in production #80

Open
bluefantail opened this issue Aug 10, 2016 · 3 comments

Comments

@bluefantail
Copy link

bluefantail commented Aug 10, 2016

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?

@charlie-hadden
Copy link

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: builtbybuffalo@dabc805. 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.

@bluefantail
Copy link
Author

@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?

@BlackRabbitt
Copy link

Is there any update regarding this bug? I am getting same one and above patch is also not working.

damianlegawiec added a commit that referenced this issue Nov 15, 2017
Fix for SystemStackError (stack level too deep) issue in production (#80)
vitkx pushed a commit to vitkx/spree_braintree_vzero that referenced this issue Sep 4, 2024
Fix for SystemStackError (stack level too deep) issue in production (spree-contrib#80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants