contribsys / faktory_worker_ruby

Faktory worker for Ruby
GNU Lesser General Public License v3.0
214 stars 31 forks source link

undefined method `jobs' for nil:NilClass #44

Closed scottrobertson closed 4 years ago

scottrobertson commented 4 years ago

Hey

Having an issue with batches on a few specific workers.

We have a batch, which enqueues jobs, and then those jobs can add to the batch. This has been working totally fine, but for some reason occasionally this happens.

undefined method `jobs' for nil:NilClass

That line is batch.jobs do

However, as you can see, there is a bid set. (it's in custom, is that right? We don't set that manually).

Screenshot 2020-01-20 at 15 39 44
scottrobertson commented 4 years ago

Ok, i have added some logging to this.

If i dump the job JSON, there is:

"custom" => {"bid" => "b-cFUpJhAhg49s1w"}

However, within the job bid is nil.

Will do some more debugging.

scottrobertson commented 4 years ago

Ok, added some more logging in the batch method in the lib.

puts self.instance_variables
=> @jid
scottrobertson commented 4 years ago

Got it. Will send PR.

mperham commented 4 years ago

See faktory/middleware/batch and faktory/job#batch

scottrobertson commented 4 years ago

@mperham PR already sent. bid was not being set on the job object at all.

scottrobertson commented 4 years ago

@mperham PR closed, let's continue the discussion here. From what i can see, that middlewhere configure_worker is just not being called at all.

mperham commented 4 years ago

require 'faktory' was called before Faktory::CLI was defined so Faktory.worker? returned false.

scottrobertson commented 4 years ago

Thanks @mperham