Skip to content

fix(react-core): degrade to source content when a runtime translation request fails during an RSC render - #2135

Closed
JoshKappler wants to merge 1 commit into
mainfrom
j/gt-sweep-1938kin
Closed

JoshKappler wants to merge 1 commit into
mainfrom
j/gt-sweep-1938kin

Conversation

@JoshKappler

@JoshKappler JoshKappler commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fixes the RSC sibling of gt-react: an invalid dev API key takes down the whole dev server during SSR #1938: a rejected runtime translation request (for example a 401 from an invalid dev API key) escaped the awaited lookups in RscT and RscTx and crashed the React Server Component render in development; both components now catch the rejection and render source content.
  • Logs one structured, deduped console error per distinct failure by moving the logger and its dedupe key out of I18nStore into a shared logRuntimeTranslationError module, so the store and the RSC render path bind to one implementation; the store keeps its per-instance dedupe set.
  • Adds a patch changeset for @generaltranslation/react-core; production behavior is unchanged since the cache already logs and falls back outside development.

Validation

  • npx vitest run on 62734ff: react-core 83 passed (17 files), gt-react 30 passed (7 files); the 4 new failure-path tests fail against the base revision's components.
  • npx tsc --noEmit in packages/react-core, npx oxlint, and npx oxfmt --check on touched paths: clean.
  • Not run: gt-next suite (it re-exports the unchanged react-core surface) and a live RSC app reproduction.

Greptile Summary

This PR prevents failed runtime translation requests from crashing React Server Component renders by logging the error and rendering source content instead.

  • Adds failure fallback handling to the RSC implementations of <T> and <Tx>.
  • Extracts structured runtime-error logging into a shared helper while preserving per-store deduplication and adding module-scoped RSC deduplication.
  • Adds regression tests for successful lookup, failed lookup, source fallback, and duplicate-log suppression.
  • Adds a patch changeset for @generaltranslation/react-core.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issues identified.

The changed RSC paths use the established undefined-target source fallback, while the extracted logger preserves existing structured logging and bounded deduplication behavior.

Important Files Changed

Filename Overview
packages/react-core/src/components/translation/T.rsc.tsx Wraps both RSC translation lookup paths in fallback handling that logs failures and passes an undefined target to the established source-rendering path.
packages/react-core/src/components/translation/Tx.rsc.tsx Adds the same logged source-content fallback to the runtime-only RSC translation path.
packages/react-core/src/utils/errors/logRuntimeTranslationError.ts Centralizes the existing structured logger and bounded deduplication behavior, with a module-scoped set for RSC renders.
packages/react-core/src/i18n-store/I18nStore.ts Delegates existing per-instance runtime-error logging to the shared helper without changing store-level deduplication scope.
packages/react-core/src/components/translation/tests/T.test.tsx Adds coverage for source fallback and logging when either standard or hot-reload RSC lookup rejects.
packages/react-core/src/components/translation/tests/Tx.test.tsx Adds success, failure fallback, and cross-render log-deduplication coverage for RscTx.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  RSC["RscT / RscTx render"] --> Lookup["Runtime translation lookup"]
  Lookup -->|Success| Target["Render translated content"]
  Lookup -->|Rejected| Catch["Catch lookup error"]
  Catch --> Log["Log structured deduplicated error"]
  Log --> Source["Render source content"]
Loading

Reviews (1): Last reviewed commit: "fix(react-core): degrade to source conte..." | Re-trigger Greptile

Context used:

… request fails during an RSC render

In development the I18nCache rethrows lookup failures, so a rejected
runtime translation request (for example a 401 from an invalid dev API
key) crashed the <T> and <Tx> RSC renders instead of rendering source
content. Catch the rejection in the RSC render path and log one
deduplicated structured error, reusing the I18nStore error logging via
a shared helper.
@JoshKappler

Copy link
Copy Markdown
Contributor Author

@greptileai review

@JoshKappler JoshKappler closed this Sep 3, 2026
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