Skip to content

Sidekiq 7 Embedding results in eval error: undefined method `map' for nil:NilClass  #156

@schlch

Description

@schlch

Hi everyone,

I recently started upgrading my Rails app to Sidekiq version 7.
Sidekiq 7 comes with a new feature called embedding (https://github.com/sidekiq/sidekiq/wiki/Embedding).
Using this feature together with this gem results in an eval error: undefined method 'map' for nil:NilClass when trying to run Sidekiq.
My Puma fileconfig looks like this:

workers 2
threads 1, 3

preload_app!

x = nil
on_worker_boot do
  x = Sidekiq.configure_embed do |config|
    # config.logger.level = Logger::DEBUG
    config.queues = %w[critical default low limited]
    config.concurrency = 2
    Sidekiq::Queue["limited"].limit = 1
    Sidekiq::Queue["limited"].process_limit = 1
  end
  x.run
end

on_worker_shutdown do
  x&.stop
end

The error occurs when calling x.run.

I did some digging and found out that the cause of this is in

@queues = config[:queues].map do |queue|

Changing this line to queues = config.queues.map do |queue| will fix the issue for me but might cause some other problems.

Could anyone guide me in the right direction as to how to fix this for everyone?

Maybe changing this to:


       @queues = (config.queues || config[:queues]).map do |queue|
          if queue.is_a? Array
            queue.first
          else
            queue
          end
        end.uniq

Will work just fine?

Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions