Skip to content

Conversation

@fxn
Copy link

@fxn fxn commented Apr 15, 2023

I may be missing something, so please consider this patch a conversation starter :).

When Rails.application.config.eager_load is true, Rails already executes

ActiveSupport.run_load_hooks(:before_eager_load, Rails.application)
Rails.application.config.eager_load_namespaces.each(&:eager_load!)

among other things.

You can check this in main, 7.0, 6.1, 6.0, ..., all the way back to 3.0 (slightly different by then).

Therefore, if config.eager_load is true, not only is this task doing unnecessary work, but it could potentially trigger code execution twice, since idempotence is not a requirement of those hooks.

For example, if you test an application with these settings:

config.before_eager_load { p :CALLED }
config.rake_eager_load = true # config.eager_load is overridden with this one for Rake tasks

you'll see :CALLED twice.

So, I suspect this might be a leftover from old Resque versions and can be entirely removed.

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

Successfully merging this pull request may close these issues.

1 participant