zombocom/rack-timeout

Puma and rack-timeout results in a null pointer after running for some time

gillesbergerp opened this issue · 1 comments

We recently tried introducing request timeouts for our Rails application using this gem. While this setup works for some time, we run into a null pointer exception at some point:

NoMethodError: undefined method `state=' for nil:NilClass
  _set_state! at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/core.rb:193
  call at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/core.rb:123
  call at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/core.rb:125
  run! at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/support/scheduler.rb:39
  run! at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/support/scheduler.rb:52
  run_loop! at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/support/scheduler.rb:100
  each at org/jruby/RubyArray.java:1865
  run_loop! at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/support/scheduler.rb:100
  loop at org/jruby/RubyKernel.java:1507
  run_loop! at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/support/scheduler.rb:81
  runner at /usr/local/bundle/gems/rack-timeout-0.6.3/lib/rack/timeout/support/scheduler.rb:73

So it appears that the env either no longer holds the state or never held it in the first place.

Our setup is as follows:

  • JRuby 9.3.4.0
  • Rails 6.1.7.2
  • Puma 6.2.1

Any help would be very much appreciated

Hmm, this looks like some kind of threading-related bug, possibly one that isn't seen in CRuby due to the GIL. Would have to review the logic and design more carefully to get to the bottom of this one.