1

Used rake rails:update, meticulously updated overwritten files, and have my rspec specs running green. But when I run rails s I hit this:

Unexpected error while processing request: stack level too deep
/Users/Alex/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.1.4/lib/active_support/cache/strategy/local_cache_middleware.rb:33

Specifically it is crapping out at response = @app.call(env) (line 26) in the above cited file.

I'm working through checklists to see if I might have missed a configuration setting somewhere. Can anyone give me a clue?

Alex Moore-Niemi
  • 2,913
  • 2
  • 24
  • 22

1 Answers1

5

So, first thing I did was get a full backtrace out of the exception by adding:

      rescue Exception => e
        puts e.backtrace
        LocalCacheRegistry.set_cache_for(local_cache_key, nil)
        raise
      end

Which then revealed one critical line before the cache middleware one I saw before:

/Users/Alex/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.1.4/lib/active_support/logger.rb:38
Unexpected error while processing request: stack level too deep
/Users/Alex/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.1.4/lib/active_support/cache/strategy/local_cache_middleware.rb:35

I jumped into the listed line which looked like this:

    define_method(:level=) do |level|
      logger.level = level
      super(level)
    end

Then searched the rest of my repo to see where I was touching logger.level. (If I hadn't been able to find the call that way, I would've used Kernel#caller.) Ahah, I discover: config/initializers/quiet_assets.rb, hmm what is this? Looks like a monkey-patch I put in an initializer ages ago:

# taken from https://stackoverflow.com/questions/6312448/how-to-disable-logging-of-asset-pipeline-sprockets-messages-in-rails-3-1
if Rails.env.development?
  Rails.application.assets.logger = Logger.new('/dev/null')
  Rails::Rack::Logger.class_eval do
    def call_with_quiet_assets(env)
      previous_level = Rails.logger.level
      Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
      call_without_quiet_assets(env)
    ensure
      Rails.logger.level = previous_level
    end
    alias_method_chain :call, :quiet_assets
  end
end

When I commented this out, poof, my error was gone and I was able to load up a page in browser. Now I've deleted the initializer and am good to go. :) For those that used How to disable logging of asset pipeline (sprockets) messages in Rails 3.1?, make sure to remove it when you upgrade!

Community
  • 1
  • 1
Alex Moore-Niemi
  • 2,913
  • 2
  • 24
  • 22