jimsynz / faye-rails

Simple Rails glue for the Faye messaging protocol.
MIT License
435 stars 79 forks source link

undefined method `pop' for nil:NilClass #91

Open clairezed opened 8 years ago

clairezed commented 8 years ago

With no identified reason and inconsistently, this error is raised once or twice a day, for an app in production, by two lines of an app in production. One of the line is called from a background task, the other isn't.

These 2 lines are refers to a version of FayeRails::Controller.publish(), that raises an error directly in eventmachine :

extract from eventmachine code

def set_deferred_status status, *args
      cancel_timeout
      @errbacks ||= nil
      @callbacks ||= nil
      @deferred_status = status
      @deferred_args = args
      case @deferred_status
      when :succeeded
        if @callbacks
          while cb = @callbacks.pop # This line raises the error =========
            cb.call(*@deferred_args)
          end
        end
        @errbacks.clear if @errbacks
      when :failed
        if @errbacks
          while eb = @errbacks.pop
            eb.call(*@deferred_args)
          end
        end
        @callbacks.clear if @callbacks
      end
    end

How comes FayeRails::Controller could have no @callbacks ? Have you met this before ?

It may be linked with my comment on #73 as it raises also on FayeRails::Controller.publish()

gwynm commented 7 years ago

Clairezed, did you ever solve this? It's just started appearing for me.

tombeynon commented 7 years ago

@clairezed @gwynm also seeing this issue, did you guys get anywhere with it? I expect it's some kind of threading edge case but will investigate further.

ohmycto commented 7 years ago

Same thing.