From 6e00a5ac1201ae77fee1ffd71412e24f50dd1198 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 06:48:39 +0000 Subject: [PATCH] perf: refactor fetchActivity to use Promise.allSettled Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com> --- src/lib/github.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/github.ts b/src/lib/github.ts index d35c21bf..fc640cd6 100644 --- a/src/lib/github.ts +++ b/src/lib/github.ts @@ -1,6 +1,5 @@ import "server-only"; import { cache } from 'react'; -import { logger } from "@/lib/logger"; import type { UserProfile, @@ -682,15 +681,14 @@ export const fetchActivity = cache(async function fetchActivity( ) ); - // Suppress unhandled promise rejections for subsequent pages if we break early or throw - promises.forEach((p) => p.catch((e) => logger.error("Event fetch promise rejected:", e))); - - for (const p of promises) { - try { - const events = await p; + const results = await Promise.allSettled(promises); + for (const result of results) { + if (result.status === "fulfilled") { + const events = result.value; allEvents.push(...events); if (events.length < 100) break; - } catch (error) { + } else { + const error = result.reason; if ( error instanceof UserNotFoundError || error instanceof RateLimitError