undefined method `each' for nil:NilClass (NoMethodError)

Eric Wong normalperson at yhbt.net
Fri Jun 22 19:34:46 UTC 2012

Claudio Poli <masterkain at gmail.com> wrote:
> Hello,
> I started getting this exception a lot: http://pastie.org/4133611
> Probably happens when a client interrupts the connection.
> Any clue?

Hi Claudio,

What can you tell us about your application?  What framework,
environment, versions are you using?

>From what I see, something in your Rack application stack is causing
an invalid Rack response (nil in the body).   A valid Rack response
is a 3 part array:

0 - status
    #to_i makes it an HTTP status code (e.g. 200, "200 OK")

1 - headers
    #each yields through a pair of stringifiable objects
    (e.g. Rack::Utils::HeaderHash, Hash)

2 - body (this is where you're getting a nil, which is wrong)
    This must respond to #each and yield a single string
    (e.g. Array, IO...)
    May optionally respond to :to_path and :closes

Eric Wong

More information about the rainbows-talk mailing list