Jaishree2310/GlassyUI-Components

[BUG] useGitHubStars cache poisoned with 0 stars during API rate limits or offline state

开放

#698 创建于 2026年6月5日

 (3 条评论) (0 个反应) (1 位负责人)TypeScript (217 个派生)auto 404
good first issuegssoc'26gssoc:approvedlevel:beginnertype:bug

仓库指标

星标
 (114 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

  1. Hit the GitHub API rate limit.
  2. Refresh the website.
  3. The website now displays ★ 0 stars, overwriting the previously correct cached count.

Suggested Fix

Check r.ok and ensure stargazers_count is a valid number before updating the cache.

贡献者指南