Jaishree2310/GlassyUI-Components
View on GitHub[BUG] useGitHubStars cache poisoned with 0 stars during API rate limits or offline state
Open
#698 opened on Jun 5, 2026
good first issuegssoc'26gssoc:approvedlevel:beginnertype:bug
Repository metrics
- Stars
- (114 stars)
- PR merge metrics
- (PR metrics pending)
Description
Description
In useGitHubStars.ts, the hook fetches stargazers count from the GitHub API but does not check if the response was successful (r.ok). Under rate limits (status 403) or offline errors, the parsed JSON is an error payload. The hook defaults data.stargazers_count to 0, setting and caching 0 stars in localStorage for a whole hour, instead of retaining the last known cached count.
Steps to Reproduce
- Hit the GitHub API rate limit.
- Refresh the website.
- The website now displays
★ 0stars, overwriting the previously correct cached count.
Suggested Fix
Check r.ok and ensure stargazers_count is a valid number before updating the cache.