fix(contributors): prevent visitor-side GitHub requests when contributor data is unavailable - #1124
Open
castrojo wants to merge 1 commit into
Open
Conversation
…tor data is unavailable When fetch-contributors.js fails to fetch commits for every file (e.g. no GitHub token during build, or rate limited), it previously wrote an empty object to file-contributors.json. PageContributors.tsx then treated every missing key as a per-page cache miss and fell back to an unauthenticated GitHub API request from each visitor's browser on every page footer. Emit a sentinel '__contributors_unavailable__' key when the build-time fetch produces zero successful results, and have PageContributors.tsx detect that sentinel and skip its client-side API fallback entirely instead of hammering the GitHub API per page. Signed-off-by: castrojo <castrojo@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1097.
fetch-contributors.jspreviously wrote an empty object tostatic/data/file-contributors.jsonwhenever every commit-fetch request for a build failed (e.g. missingGITHUB_TOKEN/GH_TOKEN, or rate limiting).PageContributors.tsxtreats any missing key in that dataset as a per-page cache miss and falls back to an unauthenticatedapi.github.comrequest from the visitor's browser — meaning every page footer on the site would hit GitHub's API directly when the build-time dataset was globally unavailable.Changes
scripts/fetch-contributors.js: when a complete fetch run finishes with zero successful files (and there were files to process), emit a sentinel__contributors_unavailable__: truepayload instead of{}.src/components/PageContributors.tsx: detect that sentinel on load and skip the client-side GitHub API fallback entirely when the whole dataset is unavailable, instead of issuing a request per page. LocalStorage cache lookups are unaffected.Testing
npx tsc --noEmit— no new errors (pre-existing unrelated error inMusicPlaylist.tsx).npx eslint src/components/PageContributors.tsx scripts/fetch-contributors.js— no new warnings/errors.node -c scripts/fetch-contributors.js— syntax OK.— hive: backend=copilot model=claude-sonnet-5
🐝 Hive Agent:
contributor| SHA:cd35e595