Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
schlch opened this issue Aug 29, 2023 · 0 comments

Comments

@schlch
Copy link

schlch commented Aug 29, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant