Fix Quota Monitoring Logic in isQuotaLow() to Check resetTime - #8956
Fix Quota Monitoring Logic in isQuotaLow() to Check resetTime#8956ChetanSenta wants to merge 3 commits into
Conversation
… passed, preventing indefinite false-positive global refresh blocking
|
Someone is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request addresses a critical bug where the isQuotaLow() function could block refresh requests indefinitely due to stale token data. By adding a check for resetTime, it ensures that refresh requests can proceed once the token's quota is restored. This change is similar in nature to previous decisions made regarding rate limit handling and cache management, which aimed to enhance performance and prevent issues related to token exposure and cache overflow. Thank you for your contribution! |
📦 Next.js Bundle Size Report (Gzipped Sizes)✨ No significant bundle size changes detected. 📊 Summary of Totals
|
Aamod007
left a comment
There was a problem hiding this comment.
Excellent fix for the Quota Monitor tests! Passing a future
esetTime\ instead of \Date.now()\ prevents the tests from instantly expiring the mocked quota and ensures accurate low-quota detection logic. Approved!
Description
Fixes #8955
Pillar
What this PR does
isQuotaLow()— which globally blocks every user's refresh request themoment ANY pooled token appears near-exhausted — only checked cached
remaining/limitvalues, never whether that token'sresetTimehadalready passed. A token that was briefly near-exhausted and then simply
wasn't re-selected long enough to get fresh headers would keep this
check blocking refreshes for everyone indefinitely, even long after
GitHub's own hourly reset had already restored that token's real quota.
getAggregateQuota()'sactiveTokenscalculation already has thecorrect
resetTime > nowcheck — applied the same pattern here.Checklist before requesting a review:
CONTRIBUTING.mdfile.npm run formatandnpm run lintlocally and resolved all errors.