em-mongo
em-mongo copied to clipboard
undefined method `docs' for :disconnected:Symbol (NoMethodError)
Whenever EM::stop is run, the unbind handler seems to produce this stacktrace:
/Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/collection.rb:739:in `block in safe_send': undefined method `docs' for :disconnected:Symbol (NoMethodError)
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `call'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `block in unbind'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `each'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-mongo-0.4.3/lib/em-mongo/connection.rb:186:in `unbind'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/eventmachine-1.0.3/lib/eventmachine.rb:1440:in `event_callback'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/eventmachine-1.0.3/lib/eventmachine.rb:194:in `release_machine'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/eventmachine-1.0.3/lib/eventmachine.rb:194:in `run'
from /Users/wolfram/.rvm/gems/ruby-1.9.3-p448@handl-server/gems/em-synchrony-1.0.3/lib/em-synchrony.rb:38:in `synchrony'
Looking at the code of EMConnection#unbind#
, it seems that it's the @responses
array holds something other than callable objects:
def unbind
if @is_connected
@responses.values.each { |resp| resp.call(:disconnected) }
...
What goes wrong here?
Update: I noticed that this only happens if an insert statement was run immediately prior to calling close
on the connection/prior to EM::stop. If there are no pending writes, it unbinds cleanly.
Not really sure. Im not actively maintaining this gem but if you have a PR to fix it I will merge!
I can't say I understand the expected values in @responses enough to patch this. But as I wrote in my update just now I noticed this problem goes away if there aren't any writes immediately prior to EM::stop. Good enough for now for me. Thanks!
@wolframarnold you can try my e-mongo fork (https://github.com/fl00r/em-mongo). I think I've pathced this bug time ago.
@fl00r would you like collab access so you can push your changes here?
@bcg thank you for offer, but I am not sure if I could maintain em-mongo because we use monga
gem in production.
Hello to Charlottesville and to Blue Moon anyway! ;)
Thank you.
Much appreciated.
Wolf
On Wed, Sep 4, 2013 at 8:43 AM, Peter Yanovich [email protected]:
@wolframarnold https://github.com/wolframarnold you can try my e-mongo fork (https://github.com/fl00r/em-mongo). I think I've pathced this bug time ago.
— Reply to this email directly or view it on GitHubhttps://github.com/bcg/em-mongo/issues/48#issuecomment-23799883 .
www.RubyFocus.biz --- San Francisco --- direct: 650-576-9048