QueueClassic/queue_classic

`QC.log_yield` hiding some exceptions

shosti opened this issue · 0 comments

Since upgrading to Ruby 2.3.0 and Rails 4.2.5, we've been getting sporadic exceptions that look like:

TypeError: can't convert nil into an exact number
  from bundle/ruby/2.3.0/bin/rake:23:in `<main>'
  from bundle/ruby/2.3.0/bin/rake:23:in `load'
  from bundle/ruby/2.3.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
  from rake/application.rb:75:in `run'
  from rake/application.rb:176:in `standard_exception_handling'
  from rake/application.rb:78:in `block in run'
  from rake/application.rb:100:in `top_level'
  from rake/application.rb:115:in `run_with_threads'
  from rake/application.rb:106:in `block in top_level'
  from rake/application.rb:106:in `each'
  from rake/application.rb:106:in `block (2 levels) in top_level'
  from rake/application.rb:150:in `invoke_task'
  from rake/task.rb:165:in `invoke'
  from rake/task.rb:172:in `invoke_with_call_chain'
  from monitor.rb:214:in `mon_synchronize'
  from rake/task.rb:179:in `block in invoke_with_call_chain'
  from rake/task.rb:235:in `execute'
  from rake/task.rb:235:in `each'
  from rake/task.rb:240:in `block in execute'
  from queue_classic_plus/tasks/work.rake:32:in `block (2 levels) in <top (required)>'
  from queue_classic/worker.rb:45:in `start'
  from queue_classic/worker.rb:71:in `work'
  from queue_classic/worker.rb:90:in `lock_job'
  from queue_classic/worker.rb:90:in `each'
  from queue_classic/worker.rb:91:in `block in lock_job'
  from queue_classic_plus/queue_classic/queue.rb:14:in `lock'
  from queue_classic.rb:82:in `log_yield'
  from queue_classic.rb:81:in `ensure in log_yield'
  from active_support/core_ext/time/calculations.rb:244:in `minus_with_coercion'
  from active_support/core_ext/time/calculations.rb:233:in `minus_with_duration'
  from active_support/core_ext/time/calculations.rb:233:in `-'

The relevant code is https://github.com/QueueClassic/queue_classic/blob/master/lib/queue_classic.rb#L75 . The only thing I can think of is that the first Time.now is throwing an exception for some strange reason (I was able to reproduce the weird exception with https://gist.github.com/shosti/085b09a2ad81879e5947 ). I'm not sure why Time.now would ever throw the exception, but in any case QC shouldn't obscure the error.