Has anyone been experiencing any issues with autoload within threads in
2.3? I have been getting some random NameErrors in situations where I
should not. I have been unable to reproduce the problem or nail down
specifically when it happens (this is why I did not put in a bug
report).
Most recently, a NameError in this gem here:
https://github.com/sparklemotion/http-cookie/blob/v1.0.2/lib/http/cookie.rb#L281 ,
even though it is clearly set to autoload here:
https://github.com/sparklemotion/http-cookie/blob/v1.0.2/lib/http/cookie.rb#L209
Some possible related issues:
opened 08:21PM - 22 Jun 15 UTC
I found the following error in my heroku logfiles:
```
NoMethodError: undefined… method `implementation' for HTTP::CookieJar::AbstractStore:Class
/app/vendor/bundle/ruby/2.2.0/gems/http-cookie-1.0.2/lib/http/cookie_jar.rb:38:in `get_impl'
/app/vendor/bundle/ruby/2.2.0/gems/http-cookie-1.0.2/lib/http/cookie_jar.rb:74:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:135:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:135:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/mechanize-2.7.3/lib/mechanize.rb:182:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/mechanize-2.7.3/lib/mechanize.rb:182:in `initialize'
```
Unfortunately I did not log the uri that was queried by my rake task, and the problem did not occur in the following hours. I still hope it's enough info to find the culprit.
opened 02:36PM - 11 Feb 15 UTC
closed 12:36AM - 03 Mar 17 UTC
activerecord
stale
Hi,
I'm not sure why this hasn't been noticed by anyone else before, but `lib/a… ctive_record/associations.rb` has this comment:
```
# These classes will be loaded when associations are created.
# So there is no need to eager load them.
```
Which is not actually true, and we are running into LoadErrors in our production systems because these files are being loaded during requests. The solution would be to wrap these in eager_load blocks as well.
Same for `lib/active_record/associations/join_dependency.rb` which does not even extend ActiveSupport::Autoload.
This should be affecting anyone who runs Rails in multithreaded mode in Puma or Passenger Enterprise, I don't know why no one noticed before now as we can very reliably produce these errors.
The solution I think is just wrapping these autoloads in eager_load blocks. No reason not to err on the side of caution with these.
Here is a test case which will fail randomly using autoload.
I will put in a bug, but can just someone confirm I am not crazy here?
Related to these:
Looks like Ruby head has fixed the issue now.