spring
spring copied to clipboard
Spring dependency on top-level keyword Session
I encountered this problem recently:
Running via Spring preloader in process 10299
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session': stack level too deep (SystemStackError)
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-5.0.1/lib/action_dispatch/testing/test_process.rb:33:in `session'
... 11898 levels...
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
First step I did was to remove spring from the binstub files bin/rails, bin/rspec, bin/rake, specifically the lines that were removed:
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
Digging a bit deeper, the root of the infinite loop rooted on:
module ActionDispatch
module TestProcess
module FixtureFile
...
def session
@request.session
end
...
end
end
Root cause:
It seems that there is a Spring dependency on a top level method / class. Not exactly sure whether it is easily reproduce-able, but it is somewhat due to my naming of an ActiveRecord as Session. As a result, when calling @request.session, it probably called the Session activerecord which subsequently triggered this TestProcess call again. I can't identify the exacts yet, hopefully I find time to dig deeper and update again! grin
Workabout:
My workabout for it was to rename my ActiveRecord class name from Session to SomethingElseSession and spring ran without any hiccups. (I know, Session as a class name is retarded to begin with - wasn't thinking that much).
Logging an issue here just to share the finding. Please go ahead and close it if its not an issue
Can you please provide a sample application that reproduces the error?