gmailgem / gmail

A Rubyesque interface to Gmail, with all the tools you'll need.
Other
397 stars 119 forks source link

fatal: No live threads left. Deadlock? #247

Closed jayqui closed 4 years ago

jayqui commented 7 years ago

I am able to establish a connection via Gmail.connect! (by supplying the appropriate xoauth2 credentials), such that storing the result in a variable called gmail returns #<Gmail::Client0x7fa1f39ca170 (me@myemailaddress) connected> every time I issue it.

However, when I try to call anything on that object, I'll get either the message fatal: No live threads left. Deadlock? or the execution will hang indefinitely.

FWIW, I'm doing this on a local Thin server, and using binding.pry to stop the code's execution.

Any thoughts on what's going on?

sriedel commented 6 years ago

I'm encountering the same issue, using Plain authentication. Fetching a list of emails from a mailbox works as expected. However, as soon I try to access an emails #envelope or #message, either the execution just hangs and the method call never returns (at least not within 5 minutes), or I immediately get the following exception:

 fatal: No live threads left. Deadlock?
  1 threads, 1 sleeps current:0x0000000001d685e0 main thread:0x0000000001d685e0
 * #<Thread:0x0000000001d9dea0 sleep_forever>
    rb_thread_t:0x0000000001d685e0 native:0x00007feda08d7700 int:0
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/monitor.rb:111:in `sleep'
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/monitor.rb:111:in `wait'
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/monitor.rb:111:in `wait'
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/net/imap.rb:1189:in `get_tagged_response'
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/net/imap.rb:1248:in `block in send_command'
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/net/imap.rb:1230:in `send_command'
    /usr/local/rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/net/imap.rb:434:in `login'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/client/plain.rb:12:in `login'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/client/base.rb:41:in `connection'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/client/base.rb:207:in `switch_to_mailbox'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/client/base.rb:164:in `block in mailbox'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/client/base.rb:161:in `synchronize'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/client/base.rb:161:in `mailbox'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/message.rb:200:in `fetch'
    /rails_root/shared/bundle/ruby/2.4.0/gems/gmail-0.6.0/lib/gmail/message.rb:30:in `envelope'

This is from within a rails 5.1.5 console. Any hint on how to handle this situation would be appreciated.

johnnyshields commented 4 years ago

As of version 0.7.0 (Aug 19, 2018) this gem is officially deprecated and will no longer be maintained. Please instead use Google's official Gmail API Ruby Client, which uses the Gmail API rather than IMAP and has significantly better performance and reliability.