Skip to content

fix(bundle): raise the App chunk budget to the size main already ships - #12606

Closed
chenmingwei23 wants to merge 1 commit into
mainfrom
fix/app-chunk-budget-drift
Closed

chenmingwei23 wants to merge 1 commit into
mainfrom
fix/app-chunk-budget-drift

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What is the problem?

Bundle Size Gate fails on main itself. The App chunk measures 3534.7 KB
(3,619,504 bytes) while its entry in CHUNK_BUDGETS is 3533 KB
(3,617,792 bytes), so the gate reports the chunk over budget by 1,712 bytes
with no pull request having added anything:

FAIL assets/App-*.js: 3.45 MB exceeds its 3.45 MB budget by 1.7 KB (chunk 'App')

The budget was set from a 3364.4 KB measurement with roughly 5% headroom, which
the chunk has since grown through one ordinary commit at a time.

Why this issue matters to the user

Nothing is wrong with any individual change, but every open pull request inherits
the failure, and Bundle Size Gate feeds the readiness signal. So a contributor
whose diff does not touch the frontend at all still sees a red required check, and
the natural response is to raise the number inside their own feature branch --
which buries a repository-wide defect inside an unrelated diff and makes the next
person re-derive it.

How our fix solves it

Raises only the App entry, to 3535 KB, and records the measurement and its date
in the comment beside it. Nothing else changes: one file, one entry, six lines.

The attribution was measured rather than assumed. Both figures below come from
npx vite build --mode analyze followed by node scripts/check-bundle-size.mjs,
run in the same environment with the same toolchain:

tree App chunk verdict
main at 20261b7633c5, nothing applied 3534.7 KB over budget by 1.7 KB
an unrelated open feature branch 3534.5 KB over budget by 1.5 KB

The feature branch is smaller than main on this chunk, which is what rules out
"some pull request grew it" as the explanation.

What tests we did

  • node scripts/check-bundle-size.mjs on main before the change: exits 1 and
    names the App chunk. After the change: exits 0, 697 chunks within budget.
  • The number is derived, not padded. Setting the budget to 3534 KB instead of 3535
    still fails, by 688 B, so 3535 is the smallest whole KB that fits the current
    measurement.
  • The build was reproduced in a second worktree cut fresh from main and measured
    the same 1.7 KB overshoot, so the figure is not an artifact of one working tree.
  • One control worth stating: when the plain build is used instead of
    --mode analyze, the gate exits 2 with "No bundle report" rather than
    reporting a pass. Exit 2 means the instrument could not run, and a reader
    comparing runs should not read it as a clean result.

Any other suggestions on the work

The headroom after this change is about 0.3 KB, so ordinary growth on main will
reach the ceiling again. That is deliberate rather than an oversight: the previous
entry carried 5% headroom and absorbed 170 KB of drift silently until it ran out,
and a ceiling that quietly absorbs growth stops being a signal. The trade is that
the next raise is a decision somebody makes and records, at the cost of reaching
it sooner. If the maintainers would rather not pay that maintenance, the two
alternatives are a stated headroom policy, or moving weight out of the chunk
behind a lazy import() boundary, which is a real change with its own review
surface and is deliberately not attempted here.

Pattern harvest

Rule candidate: CI

Pattern: a numeric ceiling that only runs on pull requests. Bundle Size Gate
measures the App chunk against CHUNK_BUDGETS, but nothing evaluates it on a
push to main, so growth is invisible until the next contributor opens a pull
request and inherits the red. The commit that spent the last of the headroom never
saw a failure; a stranger's unrelated diff did.

That is why this took a measurement to diagnose at all. The failure arrives
attached to whichever pull request opens next, which makes it look like that
diff's fault, and the cheapest response from inside that diff is to raise the
number locally. Running the same gate on main would attribute the growth to the
commit that caused it, while it is still one commit's worth of work to shrink.

The second half is the ceiling's own shape: the previous entry recorded "measured
3364.4 KB ... (~5% headroom)" and then silently absorbed 170 KB of growth, because
a budget with headroom cannot distinguish "still fine" from "nearly out". Nothing
in the file forced anyone to re-derive it. Recording the measurement beside the
number, as this change does, is the minimum; a gate that warns as the margin
closes would be better, and is deliberately not attempted here.

no linked issue: found while measuring why an unrelated pull request failed this
gate. The drift is on main itself, so there is no bug report to point at. The
follow-up named in the pattern harvest -- run the gate on pushes to main -- is
the part worth filing, and is not this diff.

The App chunk measures 3534.7 KB on main while its budget is 3533 KB, so the gate fails on main's own bytes and every open PR inherits the red. Raised to 3535 KB, the smallest whole KB that fits, and recorded the measurement in the comment.
@chenmingwei23
chenmingwei23 requested review from a team and Zedmor September 21, 2026 19:29
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 1d1d5cb8ba2b26e7badd7bbe21d5dd560e804899 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1d1d5cb

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 1d1d5cb8ba2b26e7badd7bbe21d5dd560e804899: <one-sentence reason>

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Sep 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 1d1d5cb8ba2b26e7badd7bbe21d5dd560e804899 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Near-zero headroom (0.3 KB) guarantees the next frontend PR must bump the budget inside its own diff — the exact anti-pattern the description condemns.

Watch

The description calls "raise the number inside their own feature branch" a defect that "buries a repository-wide defect inside an unrelated diff" — yet with 0.3 KB of headroom, any PR adding one import to the App chunk is forced to do precisely that, now as sanctioned policy. Attribution improves, but the friction lands on every frontend contributor, and the gate still never runs on main, so drift from dependency bumps merged via non-frontend PRs will again surface on a stranger's branch.
Clears when: a maintainer explicitly ratifies "each PR that grows the chunk bumps the budget in its own diff" as the intended workflow, or a small stated headroom (e.g. 1–2%) is recorded with the same measured-value comment.

Suggestions

  • The retained comment block directly above the entry still says "Preserve the documented margin at that current measurement" — it now contradicts the zero-margin stance; rewrite it in this commit so the file argues one policy, not two.
  • The root cause named in your own pattern harvest (gate never evaluates pushes to main) is a one-line workflow-trigger follow-up; file it so this raise is the last one diagnosed from a stranger's red check.

[DESIGN-REVIEWED] 1d1d5cb

@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of 1d1d5cb8ba2b26e7badd7bbe21d5dd560e804899 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Nothing to check.

[UX-REVIEWED] 1d1d5cb

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 1d1d5cb8ba2b26e7badd7bbe21d5dd560e804899 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 1d1d5cb

Verdict parsed from the review's SHA-scoped output markers for commit 1d1d5cb8ba2b26e7badd7bbe21d5dd560e804899.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 1d1d5cb8ba2b26e7badd7bbe21d5dd560e804899: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Closing: superseded by #12496, which merged to main and already raises this
entry to App: 3538 * KB.

That change covers strictly more than this one did. It accounts for main's own
1,712 B of drift and the 2,761 B its own surface adds, landing at
3,622,265 B measured with 647 B of headroom. This pull request only ever covered
main's part, at 3535 KB, so rebasing it onto current main would leave an empty
diff.

Worth recording that the two measurements were made independently and agree
exactly: 3,619,504 B for the App chunk on main's tip with no pull request code
in the tree, against a 3,617,792 B ceiling, over by 1,712 B. Both were attributed
the same way, by building pristine main in its own worktree before building a
branch on top of it. #12496 got there first and did the better job of it.

One point from this pull request's review is still live and is not fixed by
#12496. Bundle Size Gate never runs on a push to main, so the commit that
spends the last of a ceiling's headroom sees no failure, and the red surfaces on
whichever unrelated pull request opens next. The App, all and t entries now
carry four separate comments describing that same recurrence, most recently twice
in one day. Running the gate on pushes to main would attribute the growth to the
commit that caused it. Filing that is worth doing on its own and does not belong
in a budget bump.

No action needed here. Nothing from this branch needs to land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant