Skip to content

Commit 9f98a17

Browse files
JhaSourav07yash gupta
andauthored
docs(github): document fetch retry backoff constants (JhaSourav07#575)
Co-authored-by: yash gupta <you@example.com>
2 parents 39ed6cb + 440c16e commit 9f98a17

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

lib/github.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ interface GitHubRepo {
1010
language: string | null;
1111
}
1212

13+
// Maximum number of attempts (initial + retries).
1314
const MAX_RETRIES = 3;
15+
// Initial delay in ms; doubles on each retry.
1416
const BASE_DELAY_MS = 500;
1517
const CONTRIBUTION_MILESTONES = [1, 10, 100, 250, 500, 1000];
1618
const STREAK_MILESTONES = [3, 7, 30, 100];
1719
const GRAPHQL_TIMEOUT_MS = 8000; // 8s for GraphQL endpoint
1820
const REST_TIMEOUT_MS = 5000; // 5s for REST endpoints
1921

22+
// Retry delay uses exponential backoff: delay = BASE_DELAY_MS * 2^attempt.
2023
export async function fetchWithRetry(
2124
url: string,
2225
options: RequestInit,

0 commit comments

Comments
 (0)