Skip to content

Commit 5555b3d

Browse files
authored
fix: Don't retry if rate limit exceeded (DenverCoder1#403)
1 parent c4409a7 commit 5555b3d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/stats.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ function getContributionGraphs(string $user): array
6767
$decoded = is_string($contents) ? json_decode($contents) : null;
6868
// if response is empty or invalid, retry request one time
6969
if (empty($decoded) || empty($decoded->data)) {
70+
// if rate limit is exceeded, don't retry
71+
$message = $decoded->errors[0]->message ?? ($decoded->message ?? "An API error occurred.");
72+
if (str_contains($message, "rate limit exceeded")) {
73+
error_log("Error: $message");
74+
continue;
75+
}
7076
$query = buildContributionGraphQuery($user, $year);
7177
$request = getGraphQLCurlHandle($query);
7278
$contents = curl_exec($request);

0 commit comments

Comments
 (0)