Skip to content

perf: Implement request coalescing (single-flight) for user contributions fetching#5286

Merged
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
MasterJi27:perf-request-coalescing-5237
Jun 12, 2026
Merged

perf: Implement request coalescing (single-flight) for user contributions fetching#5286
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
MasterJi27:perf-request-coalescing-5237

Conversation

@MasterJi27

Copy link
Copy Markdown
Contributor

Resolves #5237. Introduces promise coalescing using an activeContributionsPromises map to prevent duplicate fetches for simultaneous concurrent requests.

Copilot AI review requested due to automatic review settings June 11, 2026 17:50
@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.

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.

This PR adds in-flight request coalescing to reduce duplicate concurrent GitHub contribution fetches for the same cache key.

Changes:

  • Introduces a module-level map to track active contribution fetch promises by cache key.
  • Wraps the uncached fetch function with a coalescing loader that reuses an existing in-flight promise.
  • Routes both cache-bypass and cached getOrSet fetches through the coalescing loader.

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

Comment thread lib/github.ts
* DATA FETCHING
* ========================================================================== */

const activeContributionsPromises = new Map<string, Promise<ExtendedContributionData>>();
Comment thread lib/github.ts
Comment on lines +544 to +553
const coalescedLoad = () => {
let pending = activeContributionsPromises.get(key);
if (!pending) {
pending = load().finally(() => {
activeContributionsPromises.delete(key);
});
activeContributionsPromises.set(key, pending);
}
return pending;
};
Comment thread lib/github.ts
* DATA FETCHING
* ========================================================================== */

const activeContributionsPromises = new Map<string, Promise<ExtendedContributionData>>();
Comment thread lib/github.ts Outdated
Comment on lines +547 to +549
pending = load().finally(() => {
activeContributionsPromises.delete(key);
});
@MasterJi27 MasterJi27 force-pushed the perf-request-coalescing-5237 branch from 9780a93 to 8b25072 Compare June 11, 2026 18:03

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

Looks solid. I'll go ahead and approve.

@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 type:devops CI/CD pipelines, workflows, dev scripts, and config labels Jun 12, 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 the contribution. I went through the changes and everything looks solid. The code is readable, well-structured, and aligns with the project conventions.

I'll go ahead and approve this PR. Thanks again for the contribution!

@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 the contribution. I went through the changes and the overall approach looks good, but there are a few issues that should be addressed before this can be merged. Most of the concerns are related to correctness and maintainability.

  • There are merge conflicts with the base branch. Please resolve them to ensure existing functionality isn't broken.

Once these issues are addressed, I'll be happy to take another look. Thanks again for the contribution.

@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 the contribution. It looks like there are merge conflicts with the base branch. Please rebase and resolve the conflicts so we can proceed with testing and merging. Thanks!

@MasterJi27 MasterJi27 force-pushed the perf-request-coalescing-5237 branch from b0da805 to 5b709bb Compare June 12, 2026 06:05
@MasterJi27

Copy link
Copy Markdown
Contributor Author

@Aamod007 all done form my side

@MasterJi27

Copy link
Copy Markdown
Contributor Author

Hi @Aamod007,

All CI checks are passing from my side. The only remaining issue is the Vercel deployment authorization, which appears to be a repository/configuration permission issue rather than a code issue.

Could you please review and approve the PR if everything looks good?

PR: #5286

Thanks.

@Aamod-Dev Aamod-Dev removed type:performance Code changes that improve performance/speed type:devops CI/CD pipelines, workflows, dev scripts, and config labels Jun 12, 2026
@Aamod-Dev

Copy link
Copy Markdown
Collaborator

Review Update
Automatically adjusted labels to meet the strict 1:1:1:1:1 category requirement.

@MasterJi27

Copy link
Copy Markdown
Contributor Author

Hi @Aamod007,

I've rebased the branch and resolved all merge conflicts. All required CI checks are passing successfully.

Could you please re-review the PR and dismiss the previous change request if everything looks good?

Thanks.

@MasterJi27 MasterJi27 force-pushed the perf-request-coalescing-5237 branch from 98a173f to 67b8e53 Compare June 12, 2026 08:03

@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 resolving the merge conflicts! Approving.

@MasterJi27

Copy link
Copy Markdown
Contributor Author

@Aamod007

Thank you for reviewing and approving my PRs.

Currently, I have the following approved PRs open:

#5364 – bug: Sanitize MongoDB operators from user-tracking payloads
#5343 – bug: Standardize timezone boundaries and evaluate active-hour grace periods for streaks
#5338 – bug: Align historical year ranges to user timezone offsets
#5286 – perf: Implement request coalescing (single-flight) for user contributions fetching
All of them have been reviewed and approved. The remaining blocker appears to be Vercel deployment authorization.

Could someone from the team please authorize the Vercel deployment and merge these PRs when convenient? It would help me continue working on additional assigned issues without having multiple approved PRs pending.

Thank you!

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 12, 2026
@JhaSourav07 JhaSourav07 merged commit d8bda20 into JhaSourav07:main Jun 12, 2026
4 of 5 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
@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
@github-actions github-actions Bot added type:performance Code changes that improve performance/speed and removed type:feature New features, additions, or enhancements labels Jun 18, 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 gssoc:needs-rebase 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 request coalescing (single-flight) for user contributions fetching

4 participants