gauteh / lieer

Fast email-fetching and sending and two-way tag synchronization between notmuch and GMail
http://lieer.gaute.vetsj.com
Other
497 stars 60 forks source link

KeyError: 'history' #22

Closed espindola closed 6 years ago

espindola commented 7 years ago

During a sync I got this exception:

log.txt

gauteh commented 7 years ago

Rafael Ávila de Espíndola writes on mai 19, 2017 0:19:

During a sync I got this exception:

Has there been a long time or very many changes since last sync? Does it happen when you re-try?

gauteh commented 7 years ago

I don't see any good reason for why this should happen, might be an API bug/inconsistency. There shouldn't be a nextPageToken if there isn't any history records.

espindola commented 7 years ago

This happened when trying to sync a few minutes of emails. It occurred again on a few retries, but went away when I tried after adding

  if not ('history' in results):
    print(results)

to debug it.

gauteh commented 7 years ago

Weird. We don't handle any rate exception or other httperrors here, but that doesn't seem to be what is happening.. I'm not sure if it is safe to just keep going, might accidentally skip some messages which are supposed to be in that next page.

gauteh commented 7 years ago

I think this issue should be submitted to the gmail api (I think that is at stackoverflow).

gauteh commented 7 years ago

Rafael Ávila de Espíndola writes on mai 19, 2017 0:24:

This happened when trying to sync a few minutes of emails. It occurred again on a few retries, but went away when I tried after adding

  if not ('history' in results):
    print(results)

to debug it.

I am going to close this issue. The api sometimes have weird crashes because of stability issues, there isn't any good reason for this to happen and its best to just fail so that we don't risk missing emails when syncing. It is a possiblity that this was just a temporary stability issue with the gmail service. The next step would be to go further to submit a bug report with the gmail api, but there isn't much hope for a response there.

espindola commented 6 years ago

For what it is worth, this just happened again. I had this change in place:

and it printed

{'historyId': '46590648'}

Cheers, Rafael

Gaute Hope notifications@github.com writes:

Closed #22.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/gauteh/gmailieer/issues/22#event-1097086734

gauteh commented 6 years ago

Rafael Ávila de Espíndola writes on juni 16, 2017 4:05:

For what it is worth, this just happened again. I had this change in place:

  • if not ('history' in results):
  • print(results)

and it printed

{'historyId': '46590648'}

Hi,

hm, weird.. I think that field should be returned with all pages anyway. Does it solve it self by just re-trying a few times? I've put in some re-trying code in master, you could check if that works.

Regards, Gaute

gauteh commented 6 years ago

Google issue: https://issuetracker.google.com/62686910, if you give it a star they will prioritize it.

espindola commented 6 years ago

Gaute Hope notifications@github.com writes:

Rafael Ávila de Espíndola writes on juni 16, 2017 4:05:

For what it is worth, this just happened again. I had this change in place:

  • if not ('history' in results):
  • print(results)

and it printed

{'historyId': '46590648'}

Hi,

hm, weird.. I think that field should be returned with all pages anyway. Does it solve it self by just re-trying a few times? I've put in some re-trying code in master, you could check if that works.

It goes away when I run it again.

Cheers, Rafael

gauteh commented 6 years ago

Let's see if this is fixed with the current re-try code.

gauteh commented 6 years ago

Repeated, delayed, tries does not work:

https://gist.github.com/yeled/40284b68963f3a1926c2b4b1bd003ec7

Would have to re-start the whole get_history_since operation, but since it currently involves yields that would have to be done from partial_pull.