Skip to content

fix: report correct cache status for cold requests (#5503)#5931

Merged
JhaSourav07 merged 6 commits into
JhaSourav07:mainfrom
vipul674:fix/stats-cache-status
Jun 21, 2026
Merged

fix: report correct cache status for cold requests (#5503)#5931
JhaSourav07 merged 6 commits into
JhaSourav07:mainfrom
vipul674:fix/stats-cache-status

Conversation

@vipul674

Copy link
Copy Markdown
Contributor

Fixes #5503

Problem

The X-Cache-Status header reported HIT for all non-bypass requests, even cold/first-time requests where no cache entry existed. This was misleading because the data was freshly fetched from GitHub API, not served from cache.

Fix

Check if the cache had data before the fetch using contributionsCache.has(). Now correctly reports:

  • MISS for cold requests (no cache entry)
  • HIT for requests served from cache
  • MISS for bypass requests

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@vipul674 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vipul674

Copy link
Copy Markdown
Contributor Author

@JhaSourav07 Ready for review.

X-Cache-Status was always HIT when bypassCache was not requested,
even for first-time/cold requests where no cache entry existed.

Now checks if the cache had data before the fetch and reports MISS
for cold requests.

Fixes JhaSourav07#5503
@vipul674 vipul674 force-pushed the fix/stats-cache-status branch from 5062f15 to 08fa6ef Compare June 18, 2026 08:34
@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jun 18, 2026
@Aamod-Dev Aamod-Dev added level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected mentor:Aamod007 labels Jun 18, 2026

@Aamod-Dev Aamod-Dev 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.

Difficulty: beginner – Fixes X-Cache-Status in route.ts by checking cache.has() before fetch, reports MISS for cold requests (5 additions, updates test).

Quality: clean – Simple correctness fix.

Type: bug – Fixes issue #5503, accurate cache reporting.

Good fix!

@Aamod-Dev Aamod-Dev 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.

Review

This PR cannot be approved in its current state due to blocking issues (status:blocked label, merge conflicts, needs-rebase label, and/or failing CI checks). Please resolve the blocking issues and re-request review.

Once unblocked, I'm happy to re-review! 💚

@vipul674 vipul674 requested a review from Aamod-Dev June 21, 2026 05:58
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Jun 21, 2026
@vipul674

Copy link
Copy Markdown
Contributor Author

@JhaSourav07 All CI checks passing! Fixed the failing tests.

What was wrong:

  • route.test.ts, route.empty-fallback.test.ts, and route.mouse-interactivity.test.ts were missing mocks for contributionsCache and cacheKey added in the PR
  • This caused 500 errors when route.ts tried to call contributionsCache.has()

Fix:

  • Added contributionsCache: { has: vi.fn().mockResolvedValue(false) } and cacheKey: vi.fn().mockReturnValue('key') mocks to all 3 test files

CI: Format/Lint/Typecheck/Test pass | Production Build pass | CodeQL pass | Analyze pass

@github-actions

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 3694.34 KB 3694.34 KB 0 B
Total CSS 296.06 KB 296.06 KB 0 B

@vipul674

Copy link
Copy Markdown
Contributor Author

@Aamod-Dev All blocking issues resolved! CI is now fully passing.

  • Format/Lint/Typecheck/Test: pass
  • Production Build: pass
  • CodeQL: pass
  • Analyze: pass

Ready for re-review. 💚

@Aamod-Dev Aamod-Dev added GSSoC 2026 bug Something isn't working labels Jun 21, 2026

@Aamod-Dev Aamod-Dev 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.

Fixing the cache reporting for cold requests is a great quality-of-life improvement for debugging API performance. Adding the mock for contributionsCache.has in the test files keeps the test suite robust. Approved!

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 21, 2026
@JhaSourav07 JhaSourav07 merged commit 3607864 into JhaSourav07:main Jun 21, 2026
7 of 8 checks passed
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @vipul674! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

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

Labels

bug Something isn't working gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. 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

Development

Successfully merging this pull request may close these issues.

bug: Stats endpoint labels cold non-refresh requests as cache hits

3 participants