ADR-0087 — The first paint does not wait for a catalogue
Status: Accepted · Date: 2026-08-29 · Track: 005 phase 04
Context
main.tsx opened with initI18n().then(() => ReactDOM.createRoot(...).render(...)):
every user, on every load, waited for GET /api/v1/languages to resolve before
a single pixel was drawn.
That shape was correct when it was written and is not now. It predates
ADR-0081: the module used to build its resources entirely from that response,
so rendering before it returned meant rendering keys. English is bundled now —
locales/en.json initialises i18next synchronously at import time — so what the
request carries is no longer the source text but the translations layered over
it, per key. There are none on a stock database, and the endpoint is reached
before the user is even authenticated.
ADR-0010 named the cost and left it to this phase: an i18n chunk and a
blocking request "for a feature with no consumers". Phase 04 is where the
feature gets its consumer, which is exactly when the cost has to be paid
honestly rather than inherited.
Decision
Start the catalogue fetch; do not await it. main.tsx calls initI18n()
and renders immediately. The bundled English is already in the store, so the
first paint is real sentences, never keys and never a blank document.
Bind the store, because the catalogue now arrives after mount.
react: { bindI18nStore: 'added' } is set on init(). react-i18next binds
languageChanged by default and no store event at all; without this,
addResourceBundle() would update the store while every mounted component went
on rendering the English underneath it — for the whole session, with no error
anywhere. Awaiting the request used to make that impossible, which is why the
default was survivable and why removing the await without this line would be a
regression dressed as a speed-up.
The failure mode is a returning user, not an edge case: lng is read from
localStorage at import, so a user who has chosen fr renders in the French
language before the French bundle exists. English fallback, then the bundle
lands. Nothing emits languageChanged — they already were in fr.
Consequences
- First paint costs one bundled catalogue and no network round trip. The i18n
chunk itself stays on the critical path and is no longer questionable: 2,894
call sites render through
t(), so it is the text. - A translation can now appear a beat after the English it replaces. That is the honest shape of a served catalogue and is visible only where one exists.
- A future language control (this phase's remaining slice) reads
availableLanguages, which is populated after mount rather than before it. It must therefore read the list reactively; a render-time snapshot would be empty. Recorded as an open item in 005's SESSION, not built here — nothing consumes the list yet, and a consumer-less mechanism is the defect this track exists to close (ADR-0079). initI18n()still resolves rather than rejects on a failed request, and that is now load-bearing rather than tidy: no caller awaits it, so a rejection would be an unhandled one.
Held by apps/web/src/i18n.firstpaint.test.tsx, watched failing against the
default binding
(evidence .station/jobs/005-i18n/evidence/first-paint-2026-08-29.md).
Source: docs/decisions/0087-the-first-paint-does-not-wait-for-a-catalogue.md