FlowCrypt / flowcrypt-browser

FlowCrypt Browser extension for Chrome and Firefox
https://flowcrypt.com
Other
372 stars 48 forks source link

"Too Many Requests: 429 Error" when executing guessContactsFromSentEmails #5697

Open sosnovsky opened 2 months ago

sosnovsky commented 2 months ago

Sometimes when composing message, after I start entering recipient email appears error popup Error searching contacts and there are such errors in console:

catch.js:45 Too Many Requests: 429 when GET-ing https://www.googleapis.com/gmail/v1/users/me/messages/188b462c4189b5a1 (no body):  -> Resource has been exhausted (e.g. check quota).

provided ajax call stack:
    at Google.gmailCall (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/google.js:40:67)
    at async Gmail.msgGet (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/gmail.js:161:24)
    at async Promise.all (index 46)
    at async Gmail.msgsGet (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/gmail.js:169:24)
    at async Gmail.extractHeadersFromMsgs (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/gmail.js:529:35)
    at async Gmail.fetchMsgsHeadersBasedOnQuery (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/gmail.js:396:24)
    at async Gmail.apiGmailLoopThroughEmailsToCompileContacts (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/gmail.js:497:37)
    at async Gmail.guessContactsFromSentEmails (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/gmail.js:375:17)

url: chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/chrome/elements/compose.htm?frameId=frame_rWjBxgpsDx&acctEmail=[SCRUBBED]&parentTabId=cs.BcSjCrXnsT

    at <async> ajax (/extension/js/common/api/shared/api.ts:98:4)
    at <async> performAjaxRequest (/extension/js/common/api/authentication/google/google-oauth.ts:128:31)
    at <async> gmailCall (/extension/js/common/api/email-provider/gmail/google.ts:19:28)
    at <async> msgGet (/extension/js/common/api/email-provider/gmail/gmail.ts:128:18)
    at <async> msgsGet (/extension/js/common/api/email-provider/gmail/gmail.ts:137:19)
    at <async> extractHeadersFromMsgs (/extension/js/common/api/email-provider/gmail/gmail.ts:454:35)
    at <async> fetchMsgsHeadersBasedOnQuery (/extension/js/common/api/email-provider/gmail/gmail.ts:333:40)
    at <async> apiGmailLoopThroughEmailsToCompileContacts (/extension/js/common/api/email-provider/gmail/gmail.ts:416:55)
    at <async> guessContactsFromSentEmails (/extension/js/common/api/email-provider/gmail/gmail.ts:282:39)

There are also several failed requests trying to fetch messages metadata (https://www.googleapis.com/gmail/v1/users/me/messages/MESSAGE_ID?format=metadata

Screenshot 2024-04-30 at 21 18 51

Currently noticed such issue only in https://github.com/FlowCrypt/flowcrypt-browser/pull/5651, but maybe it exists in master too, can't find exact steps to reproduce it, occurs randomly when composing new message.

sosnovsky commented 1 month ago

Similar error happened when I opened Encrypted inbox extension page:

catch.js:45 Too Many Requests: 429 when GET-ing https://www.googleapis.com/gmail/v1/users/me/threads/18eb8724b636ddae (no body):  -> Resource has been exhausted (e.g. check quota).

provided ajax call stack:
    at Google.gmailCall (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/google.js:40:67)
    at async Gmail.threadGet (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/api/email-provider/gmail/gmail.js:29:24)
    at async InboxListThreadsModule.renderInboxItem (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/chrome/settings/inbox/inbox-modules/inbox-list-threads-module.js:55:36)
    at async Promise.all (index 42)
    at async InboxListThreadsModule.render (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/chrome/settings/inbox/inbox-modules/inbox-list-threads-module.js:20:25)
    at async InboxView.render (chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/chrome/settings/inbox/inbox.js:50:29)
    at async chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/js/common/view.js:28:25

url: chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd/chrome/settings/inbox/inbox.htm?acctEmail=[SCRUBBED]&page=

    at <async> ajax (/extension/js/common/api/shared/api.ts:98:4)
    at <async> performAjaxRequest (/extension/js/common/api/authentication/google/google-oauth.ts:128:31)
    at <async> gmailCall (/extension/js/common/api/email-provider/gmail/google.ts:19:28)
    at <async> threadGet (/extension/js/common/api/email-provider/gmail/gmail.ts:35:21)
sosnovsky commented 1 week ago

In the latest release these errors are still happen quite often:

this one when opening encrypted inbox

message: Too Many Requests: 429 when GET-ing https://www.googleapis.com/gmail/v1/users/me/threads/THREAD_ID
url: chrome-extension://EXTENSION_ID/chrome/settings/inbox/inbox.htm 

provided ajax call stack:
at Google.gmailCall (chrome-extension://EXTENSION_ID/js/common/api/email-provider/gmail/google.js:40:67)
at async Gmail.threadGet (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/api/email-provider/gmail/gmail.js:30:24)
at async InboxListThreadsModule.renderInboxItem (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/chrome/settings/inbox/inbox-modules/inbox-list-threads-module.js:55:36)
at async Promise.all (index 25)
at async promiseAllWithLimit (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/core/common.js:479:38)
at async InboxListThreadsModule.render (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/chrome/settings/inbox/inbox-modules/inbox-list-threads-module.js:20:25)
at async InboxView.render (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/chrome/settings/inbox/inbox.js:50:29)
at async chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/view.js:28:25

and this one when entering recipient in compose modal

message: Too Many Requests: 429 when GET-ing https://www.googleapis.com/gmail/v1/users/me/messages/MESSAGE_ID
url: chrome-extension://EXTENSION_ID/chrome/elements/compose.htm 

provided ajax call stack:
at Google.gmailCall (chrome-extension://EXTENSION_ID/js/common/api/email-provider/gmail/google.js:40:67)
at async Gmail.msgGet (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/api/email-provider/gmail/gmail.js:162:24)
at async Promise.all (index 26)
at async promiseAllWithLimit (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/core/common.js:479:38)
at async Gmail.msgsGet (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/api/email-provider/gmail/gmail.js:170:24)
at async Gmail.extractHeadersFromMsgs (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/api/email-provider/gmail/gmail.js:530:35)
at async Gmail.fetchMsgsHeadersBasedOnQuery (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/api/email-provider/gmail/gmail.js:397:24)
at async Gmail.apiGmailLoopThroughEmailsToCompileContacts (chrome-extension://bnjglocicdkmhmoohhfkfkbbkejdhdgc/js/common/api/email-provider/gmail/gmail.js:498:37)

Probably we should catch these 429 errors and add some timeout before the next requests.