sidekiq / sidekiq

Simple, efficient background processing for Ruby

Home Page:https://sidekiq.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sidekiq API uninitialized when route drawing is deferred

victorsmoreira opened this issue · comments

Ruby version: ruby 3.3.2
Rails version: main
Sidekiq / Pro / Enterprise version(s): main

Since rails#52012 the route drawing is being deferred on environments with eager load set to false. The sidekiq API was loaded at this point, so when sidekiq routes weren't mounted we're unable to use the sidekiq API on rails console.

Here is how to reproduce the error:

rails new minimal --edge --minimal
cd minimal
bundle add sidekiq
sed -i 's/^gem "sidekiq".*/gem "sidekiq", github: "sidekiq/sidekiq", ref: "main"/' Gemfile
bundle
rails c
Loading development environment (Rails 8.0.0.alpha)
minimal(dev)> Sidekiq::Queue
(minimal):1
`<top (required)>': uninitialized constant Sidekiq::Queue (NameError)

Sidekiq::Queue

The API will be loaded when you load sidekiq/web.

"sidekiq" should absolutely not be loading the API as it is not meant to be an arbitrary API for public consumption (it is only used by sidekiq/web and console/testing type stuff).

Just to be clear, the rails PR that I mentioned changed the previous behavior.
Now we cannot to access the queues or sets on development console unless the file is required on the initializer.

Thanks for your quick response, Mike!

Or use require "sidekiq/api" in your console.