Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/lib/github.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "server-only";
import { cache } from 'react';
import { logger } from "@/lib/logger";

import type {
UserProfile,
Expand Down Expand Up @@ -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);

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.

P1 Early Exit Waits For Slow Pages

ページ1が 100 件未満なら activity はそこで確定しますが、Promise.allSettled(promises) はページ2・3の GitHub API 呼び出しが終わるまで処理を始めません。後続ページが遅い、またはランタイムの fetch timeout まで待つ場合、fetchUserSummary/api/dashboard/summary は不要な tail latency に引きずられます。

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/lib/github.ts
Line: 684

Comment:
**Early Exit Waits For Slow Pages**

ページ1が `100` 件未満なら activity はそこで確定しますが、`Promise.allSettled(promises)` はページ2・3の GitHub API 呼び出しが終わるまで処理を始めません。後続ページが遅い、またはランタイムの fetch timeout まで待つ場合、`fetchUserSummary``/api/dashboard/summary` は不要な tail latency に引きずられます。

How can I resolve this? If you propose a fix, please make it concise.

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
Expand Down
Loading