Closed zhongxiao37 closed 1 year ago
Do you think it's load issue? make something wrong with Zeitwerk. Can you try adding require 'application_record'
or some variation of that before the db model uses it?
Can you reproduce with the debug
gem commented out?
We also run across this issue with any class that we use in subtasks. Only on the first request, the second request will have the class loaded.
Commenting out the debug
gem does appear to have solved it 👍
We have some issues with autoloading in Ruby 3.1.1 and I will try to back port a fix for Ruby 3.1.2 if possible. A solution is to disable autoloading where possible.
I'm proposing a fix here https://github.com/ruby/ruby/pull/5788
This bug is fixed and will be released in Ruby 3.2. Sorry about that and thanks for your patience. If you want to help further, please retry your test case with the latest async on Ruby head.
Given that https://github.com/ged/ruby-pg/pull/397 is merged, I'm trying to use the
async
gem with latestruby-pg
in Rails 7. However, it seems that I could not use a database connection to two separated subtasks.Here is the example:
Error log
app/models/post.rb
app/models/user.rb
app/controllers/application_controller.rb
Gemfile
Gemfile.lock
Notes
If I change them in one subtask, it will work well.
app/controllers/application_controller.rb