This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(console): resolve the pre-boot branding origin from VITE_SERVER_URL - #5732
Merged
Merged
Conversation
The inline pre-boot branding script read `window.__CONSOLE_SERVER_URL`, a global nothing in this repository ever sets, while every module-side consumer reads `import.meta.env.VITE_SERVER_URL`. The two callers of `GET /api/v1/runtime/config` share one in-flight request and that sharing keys on the FULL URL, so the origin was half of the contract: whenever the two spellings disagreed the callers never found each other. Same-origin production hid it completely — both collapse to '' — so the split surfaced only in a dev pointing the console at a separate server, where it cost two requests to two different servers and let pre-boot branding paint from the wrong one. The pre-boot fetch is kept rather than deleted: it is the request the module side joins. `sharedGetJson()` can only hand an earlier request to a later caller, and this script is the earlier one by construction. Fixes #5660 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EuPCi56cnGyykygi3z9w4m
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
This was referenced Aug 23, 2026
os-zhuang
marked this pull request as ready for review
August 23, 2026 02:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5660
The branch this card asked for, and how it was decided
Triage's first-touch was a check-first, not a patch: establish whether #5658's
shared in-flight promise makes the inline fetch redundant — if yes, delete it; only
if pre-boot timing is load-bearing does the variable-injection repair apply.
Measured answer: the inline fetch is not redundant, and "redundant" is the wrong
direction entirely. #5658 shares from the request that started first to the one
that started second, and the inline script is the first one by construction. It is
the producer of the shared promise;
initRuntimeConfig()is the joiner.Three readings, all reproducible:
sharedGetJson()can only flow earlier → later. It joins an entry that alreadyexists (
packages/types/src/http-inflight.ts:187) and otherwise starts its own(
:190). There is no mechanism by which a later caller serves an earlier one.one request both with the pre-boot script (
runtimeConfigBootDedup.test.ts, "letsapp-shell join the pre-boot request") and without it ("still fetches on its own when
nothing is in flight"). The count is 1 either way — so the axis on which "redundant"
would live shows no gain. What deletion changes is when: the single remaining
request moves from HTML-parse time to module-evaluation time, and
main.tsxawaitsit before
createRoot().render(). That is precisely the head start perf(console): share one in-flight GET instead of racing duplicates on boot #5658 landed tobuy.
index.htmlships a titleelement with no text and a favicon link whose href is the empty string. The pre-boot
script is the only thing that fills either before React mounts, so deletion means a
blank tab title and no favicon until the bundle boots.
Either reading alone rules deletion out. So: variable injection, per the ruling's
conditional.
The defect, stated more precisely than the card could
The card frames the cost as "the inline fetch 404s against the Vite dev origin". The
mismatch is real, but the failure mode is worse than a 404:
apps/console/vite.config.ts:709proxies
/apitoDEV_PROXY_TARGET || 'http://localhost:3000', so the inline request isgenerally served — by whichever server the proxy points at, which need not be the one
VITE_SERVER_URLnames.The load-bearing consequence is the one the sharing makes:
inflightGetKey()keys on thefull URL, so the origin is half of that hand-copied contract. Two spellings meant two
keys, so the callers never found each other. Measured on
origin/maind8afbe519byexecuting the shipped script:
Same-origin production hides it completely — both spellings collapse to
''— which iswhy #5658's dedup was measured working there.
The change
index.html's branding script now resolves its origin from Vite's HTML env substitutionof
VITE_SERVER_URL, the same variablesrc/main.tsx:65handsinitRuntimeConfig().window.__CONSOLE_SERVER_URL— a global nothing in this repository ever set — is gonefrom the executable text, so there is exactly one spelling of the origin in the page.
The unset case is handled deliberately, because it is the ordinary production build.
Vite's
htmlEnvHooksubstitutes only when the variable is present and otherwise leavesthe token verbatim:
An unsubstituted token must therefore read as same-origin
''and must never reach theURL as a path segment. No origin can begin with
%, so the leading character decides it.A note on failure fan-out, since the two requests are now shared where they were not:
this cannot starve the module path. The two are now byte-identical requests, so any
origin that rejects the inline fetch would reject
initRuntimeConfig()'s own fetchidentically — there is no case where the old split would have succeeded and the shared
one fails.
Tests
Four cases added to the file that already grades the shipped artifact. They run the real
index.htmlthrough Vite's substitution rather than a copy of the script, so a futureedit reintroducing a second spelling of the origin fails here.
Reverse verification (revert only the
index.htmlread site, keep the tests; mutationconfirmed on disk by grepping both the removed and injected text; restore proven
byte-identical to HEAD afterwards):
The
1 times, but got 2 timesis the defect itself: two requests to two servers.The six pre-existing #5544 cases stay green under the ablation, so this change does not
disturb what that card pinned.
Gates, all green on
c62ceff90(the union was run after the final commit):check:control-bytes✅ check-control-bytes: OK (scanned 4783 tracked text file(s))check-changeset-presence✅ 2 source file(s) of 1 released package(s) changed … declares 1 changeset(s)check-changeset-no-major✅ No changeset declares a `major` bump.check-changeset-fixed✅ All workspace packages are in the changeset fixed group..ts/.tsx)@object-ui/consoletype-checktsc --noEmit && tsc -b tsconfig.node.json --force, exit 0apps/consolevitestTest Files 72 passed (72) · Tests 786 passed (786)index.htmlis an unusual gate surface here, so the coverage was derived rather thanassumed: ESLint's population is
**/*.{ts,tsx}(eslint.config.js:28,:245) andmatches no
.html, so the file is covered bycheck:control-bytes— which carries nopath filter by design — and by the vitest suite that extracts and executes its text.
That suite is the real gate on this file, which is why the fix is pinned there.
Generated by Claude Code