Repository navigation
Description
Found while verifying #678, which fixed the deterministic half of #625. This is the other half, and it is the more severe one.
What it is
An intermittent hydration failure on authenticated pages — the severe variant, not the attribute warning:
Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client.
Unlike the logo id mismatch (#625/#678), this one discards the tree and re-renders. That is the cost #625 originally described, and it is still being paid — just not on every load.
Evidence that it is a race, not a difference
Three runs of scripts/audit/smoke-mobile-nav.mjs, worker /dashboard, same code each time:
| Run | Result |
|---|---|
| before #678 | errors=1 — hydration failed, tree regenerated |
| before #678 | clean, no errors |
| after #678 | errors=1 — hydration failed, tree regenerated |
It also does not reproduce in isolation. A probe matching the smoke's setup exactly — same route, viewport 390x844, deviceScaleFactor: 2, the same @scaffald:app_mode / org-slug localStorage keys, the same injected session, networkidle + 5s — reported 0 failures at every width tried (1440, 1280, 1023, 768, 390).
So: same inputs, different outcomes. Something asynchronous sometimes lands before the first client render and sometimes after.
The likely mechanism
This is #625's original hypothesis, which was right about the shape even though it was wrong about the logo:
- the session lives in localStorage, which the server cannot read, so the server renders the logged-out tree
- supabase-js loads that session asynchronously on the client
- if the load loses the race, the first client render is logged-out and matches the server — clean
- if it wins, the first client render is logged-in, the trees genuinely differ in structure, and React throws the tree away
That predicts exactly the intermittency observed, and it predicts the severity difference: a structural mismatch is regenerated, whereas the logo id was only an attribute.
Not the same as #679
#679 is a deterministic disagreement about React tree position, invisible today because nothing in the shell calls useId any more. This is a non-deterministic disagreement about tree structure, visible now, and it discards the render. They may share a root cause; they are not the same finding and should not be closed together.
Why the current gate misses it
scripts/audit/smoke-hydration.mjs passes both its legs. It loads /dashboard once per run, so a race that fires on roughly half of loads is missed about half the time — and smoke-mobile-nav only surfaces it incidentally, because it collects pageerror for reporting and does not gate on it.
Acceptance
- Characterise the race directly — instrument whether the session is present on the first client render, and correlate with whether the failure fires
- Decide the fix: cookie-backed session so the server can render authenticated (the real fix), or hold the auth-dependent subtree at the server's shape until hydration completes
- A hydration gate that fails reliably rather than ~half the time — repeat the load N times, or assert on first-render auth state rather than on the console
- Note for whoever takes this: a
_layoutmust not return a loading view in place of itsStack/Slot. Doing so makes expo-router rewrite the URL on web hydration and eat hash/query params — that broke production OAuth once already (fix(auth): OAuth callback + hydration fixes, versioned legal acceptance, web PKCE #519).
Activity
feat(jobs): make /jobs public, and stop the listing answering with 95…
feat(jobs): make /jobs public, and stop the listing answering with 95…
fix(native): the map was black in every iOS release, Office tables th…