Open lucasthomazoni opened 2 years ago
UP i'm getting randomly the same issue, any updates ?
I saw @navidmad said it happened to him randomly so I solved it by restarting my PC. Quite fun,hh.
UP i'm getting randomly the same issue, any updates ?
UP i'm getting randomly the same issue, any updates ?
Same here.... Looking forward for fix...
Same here. No updates?
Well, this is definitely still a problem but I have a few things:
My current solution is the following:
# rails_helper.rb
RSpec.configure do |config|
# ...
config.around do |example|
DatabaseCleaner.cleaning do
example.run
end
rescue NoMethodError => e
next if e.message.match? 'undefined method `state\' for nil:NilClass'
raise e
end
end
This is definitely a bit ugly, but it works 🤷
Pay attention to the asynchronous behavior of your code. The cleaner may break precisely because of asynchronous interaction with the database
@lxnewayfarer, I wish I had read your comment a few days ago. Doing a rails 7.1 upgrade had super super weird failures in the tests. Getting messages like server received message x234 from client
and all sorts of other random weird failures.
Turns out ActiveStorage::AnalyzeJob
was running asynchronously. We use sidekiq and so I hadn't set active job to run inline. 5 hours late and 1 line of code the problem was solved
Setup
Error
From time to time, if a run my specs locally it might throw the error below, the fun thing is it errors for like two or three runs and then it passes (using same seed at all times);
This error also occurs occasionally on GitHub Actions, I have to re-run my workflow some times as well to make it pass (different seeds)
Database Cleaner Config
Any idea what might be causing this error and how to fix it?
Thanks for the gem and your attention.