Skip to content

useDate: plugin path never syncs with useLocale, and a module-scope adapter leaks locale across SSR requests #798

Description

@johnleider

Surfaced by the PR #796 inspection (SSR pass); both issues predate that PR but its week-start derivation widens the blast radius from formatting to calendar layout.

  1. createDatePlugin constructs createDate eagerly at plugin-factory time (useDate/index.ts:278-288). At that moment instanceExists() is false, so the watchEffect locale-sync branch never arms and useLocale() is unavailable — the documented "integration with useLocale for automatic locale sync" does not function through the plugin path at all; only the one-shot else branch runs.

  2. Cross-request locale leakage under SSR. The idiomatic shape — export const datePlugin = createDatePlugin({ adapter: new V0DateAdapter() }) at module scope — shares one adapter instance across every request for the server's lifetime. Any write to adapter.locale (whose setter recomputes _firstDayOfWeek and _minimalDays) leaks into concurrent renders: after fix(useDate): derive week start from CLDR data when getWeekInfo is unavailable #796 that changes the calendar's first column and week numbers, not just formatting.

Suggested scope: lazy-construct the context at install time (or per-app), arm the locale sync there, and document "construct the adapter per request under SSR" on the use-date page. index.ssr.test.ts currently has zero firstDayOfWeek coverage — the missing assertions are listed in the inspection notes (Monday/Sunday/Saturday locales, firstDayOfWeek override, two adapters not sharing state, and a renderToString-vs-client grid comparison).

Metadata

Metadata

Assignees

Labels

E: useDateComposableT: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions