Repository navigation
fix(core): don't format PlainDate with the runtime's locale - #5296
josephfarina wants to merge 3 commits into
Conversation
plainDateFormat passed undefined to Intl.DateTimeFormat, so the locale resolved to whatever the runtime had. Across an SSR boundary that differs: a host with no LC_ALL emits the CLDR root form (2026 M08) where the browser renders August 2026, and every SSR'd Calendar/DateInput reports a hydration mismatch. Default to 'en', matching what useLocale() returns outside a provider, and add the optional locale parameter useLocale's docstring already points at so callers can thread the provider locale.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@nynexman4464 wdyt? |
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Reproduced in production today, in a generated appDogfooding the live Nest Studio build flow this afternoon (2026-08-21), a The offending subtree is an app-authored date field, not anything in the Server rendered Two things this clarifies that I could not show before. It is not rare. This was the first app I generated after the fix stack Internal workarounds do not cover it. We shipped a change that stops our |
|
Thanks for chasing this down — the diagnosis is right and the #5120 landed the locale parameter two hours after you opened this, so after a merge what's left here is one line:
#5303 carries the identical line and threads all five. I'd land it there rather than here — ok with that? [Reviewed by Robohands] |
|
Inline, |


The bug
plainDateFormatformats withnew Intl.DateTimeFormat(undefined, options). Anundefinedlocale resolves to the runtime's locale, and the runtime is not thesame on both sides of an SSR boundary. On a host with no
LC_ALLthe serverresolves the CLDR root and emits
2026 M08where the browser rendersAugust 2026, so React reports a hydration mismatch:Every SSR'd
Calendar/DateInputis affected. It does not need to be a datepicker the app directly renders: a shared navigation dependency can render a
DateInputon first paint, so an app can inherit the mismatch indirectly.The issue reproduced across multiple generated apps. Downstream consumers had
already worked around it by documenting it as a known upstream warning or by
hardcoding an English formatter to avoid host-dependent output.
The existing
formatSharedDatetests also assert exact strings like'Jan 25, 2026', so they pass only because CI happens to resolve English.The change
'en'is deliberate rather than arbitrary: it is whatuseLocale()alreadyreturns outside a provider, so the default agrees with the rest of the i18n
contract instead of inventing a second one. The added parameter is the seam
useLocale's own docstring already asks for —— which today is impossible, because the helper takes no locale.
Non-breaking: every existing two-argument call keeps working, and gains
determinism.
Follow-up I deliberately left out
The twelve call sites in
Calendar,useCalendarNavigation,DateRangeInputand
DateTimeInputshould threaduseLocale()so calendars are correctlylocalized as well as deterministic. That is a larger change across a hook and two
module-level helpers, and it wants a maintainer's opinion on where the provider
locale enters those files, so I have kept this PR to the defect. Happy to do it
in a follow-up if you tell me the shape you want.
Test plan
pnpm vitest run packages/core/src/utils/plainDate.test.ts— 88 pass.Three new cases: the
'en'default, an explicit'fr'(août 2026), and thedeterminism invariant that a two-argument call equals the explicit-
'en'callon any host.
tsc --noEmitandeslintclean.I could not reproduce the root-locale resolution on macOS — this laptop resolves
en-USwhateverLC_ALLsays — so the server-side half of the evidence is theproduction repro above rather than a local run.