anuraghazra/github-readme-stats · error · CustomError
GRAPHQL_ERROR
GRAPHQL_ERROR
Error message
Something went wrong while trying to retrieve the stats data using the GraphQL API.
What it means
CustomError(GRAPHQL_ERROR) thrown by fetchStats as the final fallback inside the 'res.data.errors' block: errors exist, the first error's type is not NOT_FOUND, and its message is empty/falsy. The message is a fixed 'Something went wrong while trying to retrieve the stats data using the GraphQL API.' and the secondary message is 'Please try again later'. It is a catch-all for malformed/empty GraphQL error objects.
Source
Thrown at src/fetchers/stats.js:278
startTime: commits_year ? `${commits_year}-01-01T00:00:00Z` : undefined,
});
// Catch GraphQL errors.
if (res.data.errors) {
logger.error(res.data.errors);
if (res.data.errors[0].type === "NOT_FOUND") {
throw new CustomError(
res.data.errors[0].message || "Could not fetch user.",
CustomError.USER_NOT_FOUND,
);
}
if (res.data.errors[0].message) {
throw new CustomError(
wrapTextMultiline(res.data.errors[0].message, 90, 1)[0],
res.statusText,
);
}
throw new CustomError(
"Something went wrong while trying to retrieve the stats data using the GraphQL API.",
CustomError.GRAPHQL_ERROR,
);
}
const user = res.data.data.user;
stats.name = user.name || user.login;
// if include_all_commits, fetch all commits using the REST API.
if (include_all_commits) {
stats.totalCommits = await totalCommitsFetcher(username);
} else {
stats.totalCommits = user.commits.totalCommitContributions;
}
stats.totalPRs = user.pullRequests.totalCount;
if (include_merged_pull_requests) {View on GitHub (pinned to 54a7985aee)
Solutions
- Retry the request — the secondary message explicitly says 'try again later'.
- If persistent, log res.data.errors fully to see what GitHub actually returned.
- Check GitHub API status and the configured token's validity/scopes.
- Confirm no proxy/cache layer is mangling the GraphQL response.
Defensive patterns
Strategy: retry
Try / catch
// GRAPHQL_ERROR is the documented transient fallback; retry with backoff.
try {
return await fetchStats(username);
} catch (err) {
if (err.type === CustomError.GRAPHQL_ERROR) {
await new Promise((r) => setTimeout(r, 5_000));
return fetchStats(username);
}
throw err;
} Prevention
- Treat GRAPHQL_ERROR as transient by default — the secondary message says 'try again later'.
- Log the full res.data.errors when it recurs, since the thrown message is generic by design.
When it happens
Trigger: The stats GraphQL response carries an errors array whose first element has neither type === 'NOT_FOUND' nor a usable message — e.g. GitHub returned an errors entry with only a path/locations field, or an empty-string message. The two earlier if-checks (NOT_FOUND, then non-empty message) both fall through, landing here.
Common situations: A transient GitHub GraphQL hiccup returning a minimal/empty error object; a response shape change where the message field is absent; or an intermediary (proxy/cache) stripping error fields. Rare and non-deterministic.
Related errors
AI-assisted analysis of anuraghazra/github-readme-stats@54a7985aee (2026-08-12).
Data as JSON: /api/errors/fe1e863237018da4.
Report an issue: GitHub.