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

Start async adapters after_initialize instead of once Active Job and Active Record are loaded and Rails initialized? #1297

Merged
merged 1 commit into from
Mar 24, 2024

Conversation

bensheldon
Copy link
Owner

@bensheldon bensheldon commented Mar 23, 2024

The problem with when Async Adapters are started has overall been vexing. Problems like #930 have been reported, and I experienced this in #1294.

The unfortunate part of this is that Rails.application.initialized? isn't hookable and all after_initialize callbacks happen before tha becomes true.

The major change here is that GoodJob is now initialized before Puma finishes booting, which means that sometimes GoodJob will run before the Puma banner is output.

Why did this work before? In some apps, ActiveRecord::Base would not be loaded during initialization. Then, during the first web request and after initialized? the hook would be called and GoodJob's async adapters would start.

Why didn't this work before? In other apps, ActiveRecord::Base would be loaded during initialization and before initialized?. This led to GoodJob's async adapters never being started.

@bensheldon bensheldon force-pushed the autoload branch 2 times, most recently from 00336bb to dd73200 Compare March 24, 2024 00:41
…d Active Record are loaded and Rails initialized?
@bensheldon bensheldon added the bug Something isn't working label Mar 24, 2024
@bensheldon bensheldon merged commit cb41396 into main Mar 24, 2024
20 checks passed
@bensheldon bensheldon deleted the autoload branch March 24, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

1 participant