Skip to content

TRAC-1161: fix - Set request locale in generateMetadata before data fetch#3112

Open
jairo-bc wants to merge 2 commits into
canaryfrom
jairopanduro/ltrac-1220-product-translations-fall-back-to-default-after-revalidation
Open

TRAC-1161: fix - Set request locale in generateMetadata before data fetch#3112
jairo-bc wants to merge 2 commits into
canaryfrom
jairopanduro/ltrac-1220-product-translations-fall-back-to-default-after-revalidation

Conversation

@jairo-bc

@jairo-bc jairo-bc commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Jira: TRAC-1161

What/Why?

  • Product/category/brand content falls back to the default language after ISR revalidation; next-intl UI strings stay correct.
  • Cause: generateMetadata fetches data via cache()-memoized loaders before setRequestLocale.
  • On ISR regen (no request) getServerLocale()undefined → client omits Accept-Language → default-locale content is fetched and poisons the memoized cache for the whole render.
  • Masked on live requests (middleware sets the locale header), so it only surfaces on background regeneration.
  • Fix: call setRequestLocale(locale) before the fetch in each generateMetadata — matches next-intl's static-rendering requirement.

Testing

  • tsc --noEmit clean for edited files.
  • Runtime repro (prod build only — not next dev): set small DEFAULT_REVALIDATE_TARGET, build && start, load a non-default-locale page, wait past revalidate, reload twice → content stays translated (before fix: flips to default).
  • Requires a store with a non-default active language + product translations.
  • Manual testing

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview, Comment Jul 16, 2026 7:04pm

Request Review

@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1fd56c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…etch

generateMetadata runs before the page body and fetches page data via
cache()-memoized loaders without first calling setRequestLocale. During
ISR regeneration there is no request, so next-intl getServerLocale()
returns undefined, the storefront client omits Accept-Language, and
BigCommerce serves default-locale content that poisons the memoized
cache for the whole render.

Call setRequestLocale(locale) before the fetch in each generateMetadata.

Fixes TRAC-1161
@jairo-bc
jairo-bc force-pushed the jairopanduro/ltrac-1220-product-translations-fall-back-to-default-after-revalidation branch from 488be3a to c57f282 Compare July 16, 2026 18:22
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Report

Comparing against baseline from 5ca4c61 (2026-07-16).

No bundle size changes detected.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Unlighthouse Performance Comparison — Vercel

Comparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores.

Summary Score

Aggregate score across all categories as reported by Unlighthouse.

Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Score 90 93 92 94

Category Scores

Category Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Performance 71 85 72 83
Accessibility 95 92 95 92
Best Practices 100 100 100 100
SEO 100 88 88 100

Core Web Vitals

Metric Prod Desktop Prod Mobile Preview Desktop Preview Mobile
LCP 3.6 s 4.4 s 5.6 s 4.6 s
CLS 0.001 0 0.037 0
FCP 1.1 s 1.1 s 1.1 s 1.1 s
TBT 0 ms 0 ms 0 ms 0 ms
Max Potential FID 50 ms 40 ms 40 ms 40 ms
Time to Interactive 3.6 s 4.4 s 5.6 s 4.6 s

Full Unlighthouse report →

@jairo-bc
jairo-bc marked this pull request as ready for review July 16, 2026 19:17
@jairo-bc
jairo-bc requested a review from a team as a code owner July 16, 2026 19:17
@jairo-bc
jairo-bc added this pull request to the merge queue Jul 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 17, 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.

2 participants