feat: implement SWR cache-control headers and resolve edge runtime compilation errors (#4152)#4746
Conversation
|
@thakurakanksha288 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
🚨 Hey @thakurakanksha288, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
|
Hi @JhaSourav07, I have updated the streak API route (app/api/streak/route.ts) to fix the failing CI checks. 🛠️ What changed? Web Crypto Environment Fallback: Added a lightweight string hashing fallback mechanism to generateETag so it no longer breaks or throws runtime errors in simulated Jest/Vitest Node testing environments where crypto.subtle might be undefined. Prettier Mismatches Cleaned: Fixed nested multi-line indentation layouts to fully conform with the repository's strict formatting standards. The test suite and Prettier check are now passing perfectly. Ready for your review and merge! 🚀 Thanks! |
|
hi @JhaSourav07, kindly check once again. |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Appreciate you taking the time to submit this PR. I went through the implementation and the approach looks solid.
Everything looks good. Approving this now.
🛠️ Description
close #4152
This PR implements fine-tuned Stale-While-Revalidate (SWR) Cache-Control headers for the dynamic SVG generation routes inside
app/api/streak/route.ts.Without proper cache directives, high burst traffic from embedded GitHub Profile README views forces repeated, expensive upstream GraphQL API queries. This implementation configures edge networks (Vercel/Cloudflare) to instantaneously serve cached monolith SVGs while asynchronously refreshing data fields in the background.
Additionally, this PR addresses critical compilation blocks and Edge runtime errors discovered during local environment verification.
🚀 Changes Implemented
public, max-age=3600, s-maxage=${secondsToMidnight}, stale-while-revalidate=86400, must-revalidate).cryptomodule for standardcrypto.subtle.digestcalls, successfully eliminating Next.js Serverless/Edge environment compilation warnings.GEThandlers and error-response mapping handlers.public, s-maxage=31536000, immutable) for past year analytics queries since historical commit distributions never change.🧪 Verification & Local Testing
npm run devwith Next.js compiling cleanly without import squiggles.