Skip to content

Commit

Permalink
fix rate limiter catching 429s that are not related to the main reque…
Browse files Browse the repository at this point in the history
…st rate limit
  • Loading branch information
d-fischer committed Dec 15, 2021
1 parent 1791de1 commit 77af842
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/api/src/api/helix/HelixRateLimiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export class HelixRateLimiter extends ResponseBasedRateLimiter<TwitchApiCallOpti
}

protected needsToRetryAfter(res: Response): number | null {
if (res.status === 429) {
if (
res.status === 429 &&
(!res.headers.has('ratelimit-remaining') || Number(res.headers.get('ratelimit-remaining')!) === 0)
) {
return +res.headers.get('ratelimit-reset')! * 1000 - Date.now();
}
return null;
Expand Down

0 comments on commit 77af842

Please sign in to comment.