Skip to content

Fix Quota Monitoring Logic in isQuotaLow() to Check resetTime - #8956

Open
ChetanSenta wants to merge 3 commits into
JhaSourav07:mainfrom
ChetanSenta:fix/quota-monitor-stale-reset-check
Open

Fix Quota Monitoring Logic in isQuotaLow() to Check resetTime#8956
ChetanSenta wants to merge 3 commits into
JhaSourav07:mainfrom
ChetanSenta:fix/quota-monitor-stale-reset-check

Conversation

@ChetanSenta

Copy link
Copy Markdown
Contributor

Description

Fixes #8955

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

What this PR does

isQuotaLow() — which globally blocks every user's refresh request the
moment ANY pooled token appears near-exhausted — only checked cached
remaining/limit values, never whether that token's resetTime had
already 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()'s activeTokens calculation already has the
correct resetTime > now check — applied the same pattern here.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally.
  • I have run npm run format and npm run lint locally and resolved all errors.
  • My commits follow the Conventional Commits format.
  • I have made sure that I have only one commit to merge in this PR.

… passed, preventing indefinite false-positive global refresh blocking
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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.

@retenta-bot

retenta-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

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!

@retenta-bot retenta-bot Bot changed the title fix(quota-monitor): isQuotaLow() now checks resetTime — stale exhausted-token data no longer blocks refreshes forever Fix Quota Monitoring Logic in isQuotaLow() to Check resetTime Aug 7, 2026
@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Aug 7, 2026
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 4998.89 KB 4998.89 KB 0 B
Total CSS 354.18 KB 354.18 KB 0 B

@Aamod007 Aamod007 added level:intermediate Moderate complexity tasks quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected mentor:Aamod007 labels Aug 9, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:needs-rebase level:intermediate Moderate complexity tasks mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected

Projects

None yet

3 participants