-
Notifications
You must be signed in to change notification settings - Fork 125
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
NameError uninitialized constant X, but works several minutes later on retry #276
Comments
Hey @kaka-ruto, thanks for this. I'm quite puzzled about why this could happen. We don't do anything special with the class, not even try to instantiate it... we just pass the serialized data over to Active Job, where it's deserialized and instantiated. It's really strange. What is the exact path to the file that defines |
Thanks for having a look @rosa I found it very strange too. The To just be sure the issue was not in the mailer, I decided to first call a job that will the call the mailer. I placed the job in class NewsletterSubscribers::SendWelcomeEmailJob < ApplicationJob
queue_as :real_time
def perform(email)
NewsletterMailer.with(email: email).welcome_email.deliver_later
end
end And now the error that I get is However, when I use It appears to me that when the worker is running, it has not yet loaded my classes, which is strange. I thought it was a zeitwerk issue related to some deprecations that came into effect in rails 7.1 but I cannot seem to find any in my usage. Very strange. |
Update: Enqueueing of the job works well, but when the worker tries to execute/run the job, it cannot find the class! However, when I added this on an initializer, requiring the job class, it works! I cannot figure out why this is happening. Any ideas? Rails.application.config.to_prepare do
require Rails.root.join("app/jobs/newsletter_subscribers/send_welcome_email_job.rb")
end |
Huh... silly question.. do you have |
Hey @kaka-ruto, did you make any progress on this one at all? Is the error still happening? |
This may be due to the fact that SolidQueue was originally started by a Rake Task Rake Task is not However, if you start SolidQueue with If you have difficulty updating SolidQueue, you can set Sorry if this is irrelevant to the case. |
@tmimura39, that's a great theory! It seems it came up in the forum thread, and the thing is that even if eager loading is disabled, the class should be loaded automatically by Zeitwerk 🤔 It's super weird! |
In fact, one of the Rails products I know of that uses SolidQueue has a problem where constants cannot be referenced and errors “sometimes” occur. |
Ohhh, interesting! Yes, it'd be quite useful to know that, and if |
Hi @rosa ! It was still happening when I last tested two weeks ago. I then switched to using the |
Thank you! Could you also let me know what is the exact path to the file that defines |
Sorry for interrupting. After starting SolidQueue with the following settings, the constant reference error no longer occurs (SolidQueue version is v0.3.4, by the way). config.rake_eager_load = true My problem still seemed to be solved by eager_load. |
Ooh, @tmimura39, that's super helpful and great to know! Thank you so much 🙏 🙏 ❤️ |
I have a
NewsletterMailer
class inside the mailers directoryThat is being called in one of the controllers this way
When the subscriber is created, the job is scheduled, except I get an error with the following logs
This is the raw data
Here's the weird thing, when I retry the job a couple of minutes later on Mission Control, about more than 10 minutes later, it works and the jobs succeeds! The email is sent without error.
And using
deliver_now
instead ofdeliver_later
works wellAlso, this error does not occur in development
I am using
solid_queue
version0.4.1
with the default configuration, Rails 7.1.3.4, Ruby 3.3.4The text was updated successfully, but these errors were encountered: