fix: avoid 500s on component pages from cached empty readme - #730
Open
vvtimofeev wants to merge 1 commit into
Open
fix: avoid 500s on component pages from cached empty readme#730vvtimofeev wants to merge 1 commit into
vvtimofeev wants to merge 1 commit into
Conversation
- Fetch readme/changelog/CODEOWNERS through the authenticated Octokit client instead of unauthenticated raw.githubusercontent.com requests, which share a per-IP rate limit and intermittently returned errors in production (with one retry; 404 still falls back to the default locale) - Throw on empty component readme instead of returning '', so a transient fetch failure is retried on the next request instead of being cached as valid empty content for the whole TTL - Wait for readme cache revalidation instead of immediately returning a possibly empty cache entry - Don't let a rejected in-flight query escape CacheQuery.getData past the onError handler - Respond 404 instead of 500 for components without a readme url (e.g. isComingSoon ones like /components/navigation/action-bar) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
vvtimofeev
requested review from
dgaponov,
imsitnikov and
stepanenkoxx
as code owners
August 17, 2026 18:17
dgaponov
approved these changes
Aug 17, 2026
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.
What
Fixes the intermittent 500s on
/components/<libId>/<componentId>pages reported in #729.Root cause. Component readmes were fetched from
raw.githubusercontent.comwithout authentication. Those requests share a per-IP rate limit, and when one failed,fetchComponentReadmeswallowed the error and returned''.CacheQuerythen cached that empty string as fresh content for the whole 1-hour TTL, whilefetchComponentReadmeWithCachethrows on empty content — so a single failed fetch poisoned the instance and made the page return 500 for up to an hour. With several instances behind the balancer, the same URL flapped between 200 and 500 depending on which pod served it.Changes
fetchGithubRawFilehelper) instead of unauthenticatedraw.githubusercontent.comrequests, with one retry. 404 returnsnullso locale fallback keeps working; other errors are thrown after the retry.'', so a transient failure leaves the cache in the error state and is retried on the next request instead of being cached as valid empty content.immediateResponse: false) — a request hitting a stale/errored entry gets fresh content instead of an instantnull→ 500; stale-but-present data is still served if the refetch fails.CacheQuery.getData: awaiting the in-flight query promise no longer lets its rejection escape past theonErrorhandler.isComingSooncomponents (e.g./components/navigation/action-bar) previously hit an unhandled throw and consistently returned 500 in production.Note on rate limits
This moves readme traffic from the per-IP raw limit onto the GitHub App / token API quota. Worst-case estimate is ~750 req/hour per instance (readme cache misses dominate: locales without local docs fall back to the English readme per locale). Two cheap follow-ups can cut this by an order of magnitude if needed: dedupe fallback fetches per file rather than per locale, and raise the readme cache TTL — component readmes are fetched by version tag, so their content is immutable until a redeploy.
Testing
npm run typecheck, ESLint and Prettier clean (warnings at pre-existing baseline)__NEXT_DATA__contains localized content), missingREADME-rufalls back to English with a 200 (/ru/components/date-components/calendar),/components/navigation/action-barnow returns 404 instead of 500, smoke-checked/,/libraries,/libraries/uikitin en/ruFixes #729
🤖 Generated with Claude Code