router-core: dehydrated match updatedAt (`u`) is the render's wall clock, so prerendered HTML is not reproducible (no SOURCE_DATE_EPOCH support)
Which project does this relate to?
Router
Describe the bug
@tanstack/router-core's dehydrateMatch (src/ssr/ssr-server.ts) writes each route match's updatedAt into the hydration payload as u. updatedAt is a Date.now() taken when the match loaded, so every SSR render of a page embeds the millisecond it happened to render.
For prerendered sites that means building the same sources twice yields different HTML for every page, with u: as the only difference. We hit this with a Bazel build whose dist hash is compared against the last deploy: a rebuild with no source change reported all 17 prerendered pages as drifted, and a diff showed nothing but u:1790648849835 becoming u:1790654856039 in each one.
There is no way to pin it from user land: the value is taken inside dehydrateMatch, which has no options.
The reproducible-builds convention for exactly this is the SOURCE_DATE_EPOCH environment variable (https://reproducible-builds.org/specs/source-date-epoch/), which build tools consult in place of "now" for embedded timestamps. @tanstack/start-plugin-core's sitemap has the same shape of problem (#8512, PR #8513); this is the remaining clock in the prerendered output.
Complete minimal reproduction
- Any TanStack Start app with
prerender.enabled: true. pnpm buildtwice.diff -rthe twodist/clienttrees: every prerendered.htmldiffers, and in each the only change is theu:value inside the$_TSR.routermatches array.
Expected behavior
With SOURCE_DATE_EPOCH set, the dehydrated u comes from it, so a build of unchanged sources is byte-identical. With it unset, behavior is unchanged.
Platform
- OS: Linux
@tanstack/react-router1.170.39,@tanstack/react-start1.168.58
Source: TanStack/router