undefined method 'implementation' for HTTP::CookieJar::AbstractStore:Class
Opened this issue · 12 comments
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.
I have received this error also, randomly.
I have also been seeing this appearing on Sentry. Unsure of what is triggering it.
I saw this in the logs again now. My suspicion is something related to bafb83f. We apparently auto-load these files, and in my case, the gem is being used from multiple threads concurrently - it could be a glitch in the gem or MRI related to the auto-loading.
@knu - would it be OK with you to skip the autoloading and require the abstract_store unconditionally instead? If so, I'll gladly submit a patch to hopefully solve this issue.
We still see this issue today, in 1.0.3
, on JRuby, so it doesn't appear to be MRI specific or limited to version 1.0.2
that was initially reported. Has anyone developed a workaround in the two years since this was filed?
@JasonLunn Not that I know of. I suspect that loading files late (when they are needed) have race conditions. So loading everything at once, on startup, could work - if you find a working strategy, please post the suggestions here so we can apply it (and hopefully submit a PR to the gem for it to get fixed properly).
seeing the same ... updating to latest in hope that fixes anything ... was running the same app for months and after a restart this popped up ...
The project seems unfortunately quite abandoned at the moment. 😢 No new commits since December, and 5 open pull requests.
Do we have anyone with time and energy to fork it and maintain it? Or better yet, contact the original author (@sparklemotion) to be added as a maintainer here?
The project seems unfortunately quite abandoned
I'm dealing with mechanize and its source code just told me I should use this library ..\
eager load helps, ran this for 1 month and no more issues:
# eager load http-cookie gem to avoid random error
# https://github.com/sparklemotion/http-cookie/issues/6
cookie = $LOAD_PATH.detect { |l| l.match?(/\/http-cookie-\d/) }
Dir["#{cookie}/**/*.rb"].grep_v(/mozilla_store/).sort.each { |f| require f.sub("#{cookie}/", "").sub(".rb", "") }
I'm not sure it's related, but I found a similar bug in the AbstractStore
class caching logic that can expose incomplete classes when called across threads: #27
I concur that eagerly loading it will fix the problem. I had workaround almost 4 years ago and it never happened again:
- godfat/rest-core@8b85837
- godfat/rest-core@4ed0636 (for http-client)
@jordan-thoms You might be interested about working around this problem in http-client. I found just HTTPClient.new
and throw it away while loading the application works the best: godfat/rest-core@4ed0636