From: Jam Bees Date: 2012-10-27T11:41:36+09:00 Subject: Re: [BUG] undefined method `closed?' for nil:NilClass On 25 Oct 2012, at 04:05, Robert Mitwicki wrote: > Hi > > When I try to run one of my rake where I read body from my response, > each time I've got this error message: > > .rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:2788:in > `stream_check': undefined method `closed?' for nil:NilClass > (NoMethodError) > > I checked that place and there is: > > 2788 raise IOError, 'attempt to read body out of block' if @socket.closed? > > to fix the problem I just change it to: > > 2788 raise IOError, 'attempt to read body out of block' if > @socket and @socket.closed? > > I found few similar problems on some forums but it was in different > places but the bugfix is always the same, check @socket before > @socket.closed? > There is also few more place in http.rb where @socked.closed? appear > with checking @socket: > > 1335 connect if @socket.closed? > ... > 1344 if @socket.closed? > > I am not sure but it will be good to fix them all. > > Best regards > mtfk What are you wanting fixed? As I'm reading your issue, a nil is seen and appropriately raises an undefined method error. If you can resolve the circumstances under which nil sockets can possibly occur, you have a permanent solution. Til then, you should check for nils. Jamandbees.