rtomayko / rack-cache

Real HTTP Caching for Ruby Web Apps
http://rtomayko.github.io/rack-cache/
Other
822 stars 124 forks source link

undefined method `each' for nil:NilClass - lib/rack/body_proxy.rb:31 #100

Open krainboltgreene opened 10 years ago

krainboltgreene commented 10 years ago

I've narrowed it down to rack-cache being involved. It only happens on rather large responses. This could also be a combination of rack-cache and moneta or even moneta, rack-cache, and the LRUHash storage. I'm experimenting now.

Here's my implementation:

rack.use(Rack::Cache, verbose: true, metastore: "moneta://LRUHash?expires=true", entitystore: "moneta://LRUHash?expires=true")

Here's the full request log:

source=rack-timeout id=65fd8ba3f3ae8c5573a131d6aac3fd21 timeout=15000ms state=ready at=info
source=rack-timeout id=65fd8ba3f3ae8c5573a131d6aac3fd21 timeout=15000ms duration=0ms state=active at=debug
D, [2014-09-19T13:08:02.584573 #55149] DEBUG -- :   Blankcrepe::Account::Abstract Load (42.9ms)  SELECT "accounts".* FROM "accounts"
source=rack-timeout id=65fd8ba3f3ae8c5573a131d6aac3fd21 timeout=15000ms duration=1002ms state=active at=debug
cache: [GET /accounts] miss, store
source=rack-timeout id=65fd8ba3f3ae8c5573a131d6aac3fd21 timeout=15000ms duration=1526ms state=completed at=info
::1 - - [19/Sep/2014:13:08:03 -0500] "GET /accounts HTTP/1.1" 200 3085574 1.5280
2014-09-19 13:08:03 -0500: Read error: #<NoMethodError: undefined method `each' for nil:NilClass>
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/rack-1.6.0.beta/lib/rack/body_proxy.rb:31:in `each'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/rack-1.6.0.beta/lib/rack/body_proxy.rb:31:in `each'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/rack-1.6.0.beta/lib/rack/body_proxy.rb:31:in `each'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/rack-1.6.0.beta/lib/rack/lint.rb:695:in `each'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/puma-2.9.1/lib/puma/server.rb:615:in `handle_request'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/puma-2.9.1/lib/puma/server.rb:361:in `process_client'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/puma-2.9.1/lib/puma/server.rb:254:in `block in run'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/puma-2.9.1/lib/puma/thread_pool.rb:92:in `call'
/Users/krainboltgreene/.rvm/gems/ruby-2.1.2@blankcrepe-api/gems/puma-2.9.1/lib/puma/thread_pool.rb:92:in `block in spawn_thread
krainboltgreene commented 10 years ago

@body seems to be nil in the Rack::BodyProxy class, which means it's related to #74 and possibly another instance of fcb3fbb.

krainboltgreene commented 10 years ago

This looks it's fixed, but not released? Why has it taken so long?

fabn commented 9 years ago

Got the same issue and also found a solution in https://github.com/rtomayko/rack-cache/commit/fcb3fbbc28e997964ec2a44510141a27e50bbcb2

I was then pretty surprised that an issue fixed in 2012 is not released to rubygems yet. I'll point my gemfile to github to fix this, but it would be nice to have some news from @rtomayko about the status of this project.