Skip to content

perf: Implement Next.js Edge Timeout Racer with Stale Cache fallback#5288

Merged
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
MasterJi27:perf-edge-timeout-racer-5240
Jun 12, 2026
Merged

perf: Implement Next.js Edge Timeout Racer with Stale Cache fallback#5288
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
MasterJi27:perf-edge-timeout-racer-5240

Conversation

@MasterJi27

Copy link
Copy Markdown
Contributor

Resolves #5240. Implements a 4-second timeout race using Promise.race, returning stale cached data with isOfflineFallback: true on timeout or fetch failures.

Copilot AI review requested due to automatic review settings June 11, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a timeout wrapper around GitHub contribution fetches so requests don’t hang indefinitely and the system can fall back to stale cached data, while also improving related warning messages.

Changes:

  • Introduces a Promise.race-based timeout around fetchContributionsUncached calls.
  • Uses the timeout-wrapped loader in both forced-refresh and cache getOrSet paths.
  • Updates warning messages (including fixing a typo) to mention timeouts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/github.ts Outdated
Comment on lines +542 to +553
const timeoutPromise = (ms: number) =>
new Promise<never>((_, reject) => {
const timer = setTimeout(() => reject(new Error('TimeoutRacer')), ms);
// Unref node timer if possible to prevent hanging tests
if (timer && typeof timer.unref === 'function') {
timer.unref();
}
});

const loadWithTimeout = async () => {
return Promise.race([load(), timeoutPromise(4000)]);
};
Comment thread lib/github.ts Outdated

const timeoutPromise = (ms: number) =>
new Promise<never>((_, reject) => {
const timer = setTimeout(() => reject(new Error('TimeoutRacer')), ms);
Comment thread lib/github.ts Outdated
});

const loadWithTimeout = async () => {
return Promise.race([load(), timeoutPromise(4000)]);
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@MasterJi27 MasterJi27 force-pushed the perf-edge-timeout-racer-5240 branch from 23a8bc5 to b5d4467 Compare June 11, 2026 18:04
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Hey @MasterJi27, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

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 passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jun 11, 2026
@MasterJi27 MasterJi27 force-pushed the perf-edge-timeout-racer-5240 branch from e794ad9 to 4a7bfc6 Compare June 11, 2026 18:16
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Jun 11, 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.

Thanks for putting this together. The code looks clean and solves the issue effectively.

I'm happy to approve this. Great job!

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 12, 2026
@JhaSourav07 JhaSourav07 merged commit c804fe0 into JhaSourav07:main Jun 12, 2026
3 of 4 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @MasterJi27! 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! 💻✨

@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 12, 2026
@Aamod-Dev Aamod-Dev added mentor:Aamod007 level:advanced Complex contributions involving architecture, optimization, or significant feature work quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:feature New features, additions, or enhancements type:performance Code changes that improve performance/speed and removed type:feature New features, additions, or enhancements labels Jun 12, 2026
@Aamod-Dev

Copy link
Copy Markdown
Collaborator

Review Summary
Removed extra type labels ( ype:feature) to strictly meet the rule of exactly one type label ( ype:performance retained).

@JhaSourav07 JhaSourav07 added gssoc:approved PR has been reviewed and accepted for valid contribution points and removed gssoc:approved PR has been reviewed and accepted for valid contribution points labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points level:advanced Complex contributions involving architecture, optimization, or significant feature work mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:performance Code changes that improve performance/speed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: Implement Next.js Edge Timeout Racer with Stale Cache fallback

4 participants