Skip to content

fix/docs git str c#76

Open
akii09 wants to merge 2 commits intomainfrom
fix/docs-git-str-c
Open

fix/docs git str c#76
akii09 wants to merge 2 commits intomainfrom
fix/docs-git-str-c

Conversation

@akii09
Copy link
Owner

@akii09 akii09 commented Mar 25, 2026

Description

Fixes the GitHub Star Banner to work reliably in production by implementing proper caching, error handling, and React best practices. The banner now gracefully handles API rate limits and network failures.

Related Issue

Closes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • 🚀 New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📖 Documentation update
  • 🔧 Refactor / chore (no functional changes)

Changes Made

  • Added localStorage caching: Star count cached for 1 hour to avoid repeated API calls and prevent rate limiting
  • Implemented fallback value: Uses 160 as fallback when API fails, ensuring banner always displays
  • Fixed stale closure bug: Removed redundant cache check and state dependency issues in useEffect
  • Added fetch guard: Used useRef to ensure single API call per session
  • Improved error handling: Distinguishes between abort errors and real failures
  • Added proper headers: Includes Accept: application/vnd.github.v3+json header for GitHub API

How Has This Been Tested?

  • Unit tests pass (pnpm test)
  • Type checks pass (pnpm typecheck)
  • Lint passes (pnpm lint)
  • Manually tested locally (verified cache behavior, fallback display, and dismiss functionality)

Screenshots (if applicable)

N/A - No visual changes, only reliability improvements

Checklist

  • My code follows the project's style guidelines (Biome)
  • I have performed a self-review of my code
  • I have added/updated tests that prove my fix or feature works
  • New and existing tests pass locally
  • I have updated relevant documentation (README, CONTRIBUTING.md, etc.)
  • My commits follow the Conventional Commits format

akii09 added 2 commits March 26, 2026 00:21
…ling

- Cache GitHub star count in localStorage with 1 hour TTL to reduce API calls
- Add fallback star count used if API request fails (except abort errors)
- Use ref to prevent multiple API fetches during component lifecycle
- Handle fetch abort and errors more robustly with proper headers
- Rename storage keys for clarity and avoid magic strings
- Initialize star count state from cache on component mount
- Improve code comments and error handling around localStorage usage
- Regenerated the tsconfig.tsbuildinfo to reflect recent build changes
- Ensured build info is current for incremental TypeScript builds
@vercel
Copy link

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pdfx Ready Ready Preview, Comment Mar 25, 2026 6:53pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant