http-cookie icon indicating copy to clipboard operation
http-cookie copied to clipboard

undefined method 'implementation' for HTTP::CookieJar::AbstractStore:Class

Open maia opened this issue 10 years ago • 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.

maia avatar Jun 22 '15 20:06 maia

I have received this error also, randomly.

carsonreinke avatar Feb 29 '16 14:02 carsonreinke

I have also been seeing this appearing on Sentry. Unsure of what is triggering it.

perlun avatar Apr 07 '17 09:04 perlun

I saw this in the logs again now. My suspicion is something related to https://github.com/sparklemotion/http-cookie/commit/bafb83fc060b6fac9fe1a506477206ca3a4fbf63. 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.

perlun avatar Jul 17 '17 07:07 perlun

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 avatar Jul 28 '17 14:07 JasonLunn

@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).

perlun avatar Jul 31 '17 05:07 perlun

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 ...

grosser avatar Aug 18 '17 16:08 grosser

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?

perlun avatar Sep 04 '17 05:09 perlun

The project seems unfortunately quite abandoned

I'm dealing with mechanize and its source code just told me I should use this library ..\

Nakilon avatar Oct 24 '18 13:10 Nakilon

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", "") }

Screen Shot 2019-09-19 at 1 47 37 PM

grosser avatar Aug 15 '19 20:08 grosser

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: https://github.com/sparklemotion/http-cookie/issues/27

headius avatar Oct 18 '19 01:10 headius

I concur that eagerly loading it will fix the problem. I had workaround almost 4 years ago and it never happened again:

  • https://github.com/godfat/rest-core/commit/8b85837db400f29fc8df419a3b761ddd130ed581
  • https://github.com/godfat/rest-core/commit/4ed06367675f2ecddf084abb51c00931d848de28 (for http-client)

godfat avatar Oct 18 '19 07:10 godfat

@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: https://github.com/godfat/rest-core/commit/4ed06367675f2ecddf084abb51c00931d848de28

godfat avatar Oct 18 '19 07:10 godfat