nicholaschiang / hammock

Move your newsletters outside of your inbox. Focus on and learn from the content you love in a distraction-free reading space.
https://readhammock.com
GNU Affero General Public License v3.0
11 stars 1 forks source link

perf: reduce Gmail API usage #149

Open nicholaschiang opened 3 years ago

nicholaschiang commented 3 years ago

Fixes PD-178 which, in turn, resolves a bunch of Gmail API limits related issues.

linear[bot] commented 3 years ago
PD-178 Fix rate limits problem

The nefarious bug that managed to break EVERYTHING (not just Hammock)! 😹😭💀 > Ok, and then just FYI [@Martin](https://readhammock.slack.com/team/U01TL4QUPJL) [@Juraj Pal](https://readhammock.slack.com/team/U01ST89EXSR) I'm thinking that all the bugs you've been experiencing with lagging Gmail syncing is because Hammock seems to be going over Gmail's rate limits pretty consistently (this is BAD). This has to do with the new `/api/push` sync method (where Gmail notifies Hammock of new messages) and it's excessive use of Gmail's API. Properly controlling Hammock's rate limits is difficult though, because of the serverless nature of Next.js: multiple `/api/push` function calls can be running at the same time for the same user and they (currently) don't talk to one another so there's no way to coordinate the Bottleneck limiter to ensure we don't go over Gmail's rate limits. I'll have to fix that. And then the already-implemented scrappy fix: > I fixed login by silently failing the sync while allowing the login to succeed. As for syncing, I think I might just revert back to the old `/api/sync` recursive function and disable watching for now. And the fix that needs to be implemented for this issue to be completely closed: > Until I implement a fix that creates a single Bottleneck pool of API requests per user shared across every serverless function invocation.

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

hammock – ./

🔍 Inspect: https://vercel.com/readhammock/hammock/2YPQsUW9yr1b4JWAGS26AMNMUL4J
✅ Preview: Failed

[Deployment for ef89f9f failed]