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 methodclosed?’ 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.
I understand that, but I do not know exactly when and why @socket is
created. I didn’t debug it as much. Right now I see that in most part
of this code (in http.rb) there is a if statement to check if @socket
is not nil, before using @socket.closed? but not in this two cases as
I mention in first post. So I assume that someone already figure out
why is like that and he prevent to crash in other places but forget
about this two.
Maybe you know when @socket will be created and how to prevent code to
crash in that cases?
Best regards
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.