Repository navigation
Description
Issue Description
With config.enabled_patches << :solid_queue_recurring (added in #3140), every boot with eager_load off makes Rails log its early-load-hook warning seven times, each with a full stack trace:
:active_record was loaded before application initialization.
Prematurely executing load hooks will slow down your boot time
and could cause conflicts with the load order of your application.
The other six are the same warning for :active_model_translation, :active_record_encryption, :active_model_secure_password, :active_record_postgresqladapter, :active_job and :active_job_arguments.
The cause is Sentry::Rails::SolidQueueRecurring.patch (sentry-rails/lib/sentry/rails/solid_queue_recurring.rb):
apply = proc do
if defined?(::SolidQueue::RecurringTask) && !(::SolidQueue::RecurringTask < Sentry::Rails::SolidQueueRecurring::RecurringTask)
::SolidQueue::RecurringTask.prepend(Sentry::Rails::SolidQueueRecurring::RecurringTask)
end
end
::Rails.application.reloader.to_prepare(&apply)to_prepare callbacks run in the finisher, before Rails.application.initialized? is true. ::SolidQueue::RecurringTask < ... autoloads the model, which loads SolidQueue::Record (so Active Record) and RecurringTask::Arguments (so Active Job). Rails' guard_load_hooks reports each one.
This is the same class of problem as #2912, fixed for ActionController::Live in #3109.
It matters most in rake tasks: rails db:prepare as a deploy pre-step prints all seven stack traces on every deploy.
Reproduction Steps
- Rails app with
solid_queueandsentry-rails, andconfig.enabled_patches << :solid_queue_recurringinSentry.init. - No other initializer touches Active Record or Active Job at boot.
- Run any rake task with eager loading off, e.g.
bin/rails db:version. - Check the log (
log/development.login development).
Expected Behavior
Enabling the patch doesn't load Active Record or Active Job before the app finishes initializing.
Actual Behavior
Seven "was loaded before application initialization" warnings, all with solid_queue_recurring.rb (the apply proc inside patch) in the stack.
One possible fix: the app's Zeitwerk loader owns SolidQueue::RecurringTask (it lives in the engine's app/models), so the prepend could run from a load callback instead of to_prepare. That fires when the model is first loaded and again after every reload:
::Rails.autoloaders.main.on_load("SolidQueue::RecurringTask") do |klass, _abspath|
klass.prepend(Sentry::Rails::SolidQueueRecurring::RecurringTask) unless klass < Sentry::Rails::SolidQueueRecurring::RecurringTask
endWe tested this wiring in an app: with eager loading on and off, SolidQueue::RecurringTask and ActiveJob::Base carried the same modules as with the built-in patch, and the warnings went away.
Ruby Version
4.0.2
SDK Version
sentry-rails 7.2.0 (same code in 7.3.0 and on master)
Integration and Its Version
Rails 8.2.0.alpha (edge), solid_queue 1.7.2, Rake
Sentry Config
Sentry.init do |config|
config.enabled_patches << :solid_queue_recurring
endMetadata
Metadata
Assignees
Projects
- StatusShow more project fieldsWaiting for: Product Owner
Activity
linear-code commentedon Nov 24, 2026
RUBY-255