From 35ce9c771b11a5a61584ece6ec7b0f6daa3bc05e Mon Sep 17 00:00:00 2001 From: GaneshDeshmane Date: Tue, 23 Jun 2026 19:02:43 +0530 Subject: [PATCH] fix: prevent mutation of repos array while sorting top repositories --- jsconfig.json | 1 + src/app/api/stats/route.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/jsconfig.json b/jsconfig.json index 2c8ee2bb..039f7d57 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "baseUrl": ".", + "ignoreDeprecations": "6.0", "paths": { "@/*": ["src/*"] } diff --git a/src/app/api/stats/route.js b/src/app/api/stats/route.js index 38adec58..54b0b081 100644 --- a/src/app/api/stats/route.js +++ b/src/app/api/stats/route.js @@ -58,7 +58,11 @@ export async function GET() { // Fetching contributors for ALL repos consumes too much rate limit (N requests). // We will proactively fetch contributors for the top 6 most starred/popular repos to get a good estimate. // Sorting repos by stargazers_count - const topRepos = repos.sort((a, b) => b.stargazers_count - a.stargazers_count).slice(0, 6); + + const topRepos = [...repos] + .sort((a, b) => b.stargazers_count - a.stargazers_count) + .slice(0, 6); + const contributorIds = new Set();