Files
sim/apps
Waleed 5da48d015a fix(env): assign window.__ENV directly instead of queueing it (#6494)
`<EnvScript>` defaults to Next's `<Script strategy='beforeInteractive'>`, which
does not assign `window.__ENV` — it pushes the assignment onto `self.__next_s`.
That queue has one consumer, `appBootstrap`, which reads it once and
short-circuits to `hydrate()` when empty. The bootstrap chunk's `<script async>`
tag sits ~13KB earlier in the document than the env tag, so when that chunk runs
first the queue drains empty, nothing drains it again, and `window.__ENV` stays
undefined for the life of the document — every `getEnv` read empty until a
reload wins the race.

`disableNextScript` emits a plain inline `<script>` that assigns
unconditionally, so a lost race costs a few milliseconds instead of the session.

Also records whether the assignment was still missing at module-init so the
residual (module-scope reads in `env-flags`, which freeze what they see) is
measured rather than assumed.
2026-08-10 11:01:40 -07:00
..
…