tarasglek / chatcraft.org

Developer-oriented ChatGPT clone
https://chatcraft.org/
MIT License
147 stars 26 forks source link

Use Exponential Backoff for downloading large messages #650

Closed Amnish04 closed 3 weeks ago

Amnish04 commented 3 weeks ago

In https://github.com/tarasglek/chatcraft.org/pull/627#issuecomment-2095352160, I was advised to use exponential backoff to counter rate limiting of 3 RPM on HQ TTS downloads.

In this PR, I am using the exponential-backoff package to retry any failed operations with increasing delays between failed attempts.

The package size was around 36 kb, so I am using dynamic import to only load it when needed.

Here's how the network tab looks when downloading,

ExponentialBackoff

I think I can optimize it more by increasing the startingDelay value, so we don't bombard so many requests. Not sure what else could be better.

This fixes #632

cloudflare-pages[bot] commented 3 weeks ago

Deploying chatcraft-org with  Cloudflare Pages  Cloudflare Pages

Latest commit: e49090b
Status: ✅  Deploy successful!
Preview URL: https://36a1bf27.console-overthinker-dev.pages.dev
Branch Preview URL: https://amnish04-exponential-backoff.console-overthinker-dev.pages.dev

View logs