tpitale / mail_room

Forward mail from gmail IMAP to a callback URL or job worker, simply.
MIT License
195 stars 51 forks source link

Use `imap` method instead of instance variable #112

Closed cablett closed 4 years ago

cablett commented 4 years ago

Hi @tpitale ! Hope you're keeping well.

We ran into a problem with mail_room restarting and running into this error:

stack trace (snipped/modified slightly for clarity)

lib/mail_room/mailbox_watcher.rb:33 run> terminated with exception (report_on_exception is true):
lib/mail_room/connection.rb:177:in `new_message_ids': undefined method `uid_search' for nil:NilClass (NoMethodError)
lib/mail_room/connection.rb:166:in `new_messages'
lib/mail_room/connection.rb:137:in `process_mailbox'
lib/mail_room/connection.rb:51:in `wait'
lib/mail_room/mailbox_watcher.rb:35:in `block in run'
bundler: failed to load command: mail_room (bin/mail_room)
NoMethodError: undefined method `uid_search' for nil:NilClass
lib/mail_room/connection.rb:177:in `new_message_ids'
lib/mail_room/connection.rb:166:in `new_messages'
lib/mail_room/connection.rb:137:in `process_mailbox'
lib/mail_room/connection.rb:51:in `wait'
lib/mail_room/mailbox_watcher.rb:35:in `block in run'
Runit: waiting 5 seconds before restarting mail_room

I'm not sure why the instance variable @imap is used rather than the method, so I modified it in case this was not intentional.

We could also try @imap&.uid_search but I'm not sure that's any better 😅

What do you think?

tpitale commented 4 years ago

I must not have caught that in this PR/commit: https://github.com/tpitale/mail_room/commit/ad05657b569f44a9afe3d7a9d9e10efbecfeb074#diff-1584ba8464140d371ca07979eada7887R170

cablett commented 4 years ago

Thank you! 🙌