tmdb-ts
tmdb-ts copied to clipboard
Feature Request: Retries when rate limited
Is your feature request related to a problem? Please describe. It would be nice if there was a built in retry mechanism, specifically for when TMDB responds back with a rate limit error (https://developer.themoviedb.org/docs/rate-limiting)
I plan to build something that would potentially have multiple nodes/workers that call TMDB's API, and it'd be great if when I hit the rate limit, intentionally or not, that the library waits the suggested wait time provided by TMDB.
Describe the solution you'd like
Add a flag to enable retry, where when TMDB returns a 429 response, retry the request based on the response's Retry-After header.
Describe alternatives you've considered
I've considered just adding in a manual retry if this library throws an exception, but it'd be nice if I pass along a retry enabled flag so that the library can deal with retries for me.
Additional context
A Golang version of the TMDB library seems to do this: https://github.com/cyruzin/golang-tmdb/blob/550e16359e0dc11bee79cdda30c470f7b96081a2/tmdb.go#L189
A JS version seems to have also implemented this: https://github.com/gajus/tmdb/blob/master/src/Tmdb.js#L49
Edit: I'm honestly not sure if either strategies work... I can tell that TMDB is using CloudFront, but to be honest I'm not sure how to tell when CloudFront rate limits or if they return any headers on when they can retry.
Hmm is this still something you want to see @benlei ?
@blakejoy Yep would be nice if this was built in
any update?
The CDN changed so I don’t know if there’s an easy way to implement as it was before @Sisableng