Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


undefined method `each' for nil:NilClass in asset pipeline with perform_caching = true #8366

freegenie opened this Issue · 17 comments

8 participants


I'm on a Rails 3.2.8 app with caching enabled in development mode using mem_cache_store.

I'm getting this error while fetching /assets/application.js

Internal Server Error

undefined method `each' for nil:NilClass

this is the backtrace:

    /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:71:in `service'
    /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

I'm using Ruby 1.9.3-p194 on OSX 10.8.2

My application.js file is quite big (a lot of requires) but this problem does not seem to be related to any of the required files nor to any line of code in the file itself. It seems rather to be related to the overall generated file, maybe the size.


I tried to reproduce and created a new app 3.2.9 with cache_classes = true and mem_cache_store. Requesting application.js works just fine...

@freegenie can you please put together a sample app on github that has the problem? Otherwise it's very hard to debug.


did you mean config.perform_caching = true? I'm pretty sure It's something related to some edge case or gem combination. I'm working on it.


I just checked 3.2.9 and ruby 1.9.3-p327 and I have the same error.


Does not happen specifing file_store instead of mem_cache_store.


Tried in a vanilla app, with the same amount of javascript files. Same behaviour, definitely something related to memcache_client.


@freegenie can you publish a sample app so that I can take a look?


you know that's related to tons of javascript files I can't publish right now, but, yes, I'll try to reproduce it with dummy js data and publish a sample.


I had the exact same problem after setting config.cache_store = :dalli_store. I could solve it by deactivating Rack::Cache middleware explicitly (config.action_dispatch.rack_cache = nil), or by setting

config.action_dispatch.rack_cache = {
  :metastore    =>,
  :entitystore  => 'file:tmp/cache/rack/body',
  :allow_reload => false

I'm trying to reproduce this in plain new app but no luck so far.


Days after I'm no longer able to reproduce this issue. Closing.

@freegenie freegenie closed this

Ok it's happening again, seems to be releated to rack-cache that sometimes sets body to nil instead of an Array. I'm following this on the rack-cache side.


I have the exact same problem on heroku. I'm using 3.2.9 and ruby 1.9.3-p327.


I ran into the same issue today with Rails 3.2.12, Ruby 1.9.3 p194, Dalli 2.6.2, and Rack-Cache 1.2.

I was able to use @lacco solution to resolve the issue, but seems the underlying issue is still unresolved. I'll post an update if I find out anything further.


Confirming the issue with rails 3.1.11, and confirming that @lacco's answer fixed it:

config.action_dispatch.rack_cache = nil
@captbunzo captbunzo referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.

Also confirming that @lacco's solution fixed it... Ruby 2.0.0, Rails 3.2.17, Dalli 2.6.4, Rack-Cache 1.2. Thanks @lacco, bizarre indeed.

My issue is that the assets were loading fine from S3, but from CloudFront the assets were returning 200 with content, but the top of the content had a line saying HTTP 1.1 500 Internal Server Error. Something about how CloudFront is calling S3 I presume, similar to this issue.


FWIW, my current workaround is setting :cache => true in my dali configuration in config.cache_store.


It seems like this is related to the cache store being exceeded when serving large files. I see the following message in my development.log when this happens:

Value for myproject:05020f2107f569bbca42b7f1g4128d26f3e563a6 over max size: 1048576 <= 5000017

Is there any real solution for this besides setting compression or disabling rack cache?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.