Skip to content

fix(hydration): report a server-empty list once when the client has items - #1542

Merged
trueadm merged 10 commits into
mainfrom
fix/empty-list-hydration-report
Oct 2, 2026
Merged

trueadm merged 10 commits into
mainfrom
fix/empty-list-hydration-report

Conversation

@trueadm

@trueadm trueadm commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Hydrating an @for that the server rendered with zero items, while the client has items, now produces exactly one structural diagnostic and one recoverable error, at the list's own site.

Before, a dev compile logged two diagnostics for that one mismatch:

  1. the client expected a populated list but the server rendered an empty list (@empty). This was misleading when the list has no @empty arm.
  2. the client expected another list item but the server rendered nothing, from the first item's fewer-items recovery.

The same double report happened when the server really did render @empty, where line 2 was also wrong because the server had rendered the arm's content. When a pending sibling (a lazy() child) held the attempt and it replayed, line 1 fired a third time. That warning called warnStructural directly, so it skipped the record of ranges an earlier attempt rebuilt and the stale-captures check.

Status after #1555: main now reports the server-empty case once (including retries and dormant boundaries) through reportRebuiltRange, but its warning still says the server rendered an empty list (@empty) when the list has no @empty arm. Against current main, this PR:

  • fixes that wording, which is the only user-visible change and the only thing the changeset now describes;
  • replaces main's inline save/report/warn/remove in forBlock's server-empty branch, and fix(hydration): report a server-populated list rebuilt as @empty #1559's discardPopulatedList, with one shared discardListArm, which makes the bundle changes below; and
  • adds regression coverage for both directions' replay and dormant cases on this path.

Changes

Validation

  • pnpm format:check (not run repo-wide; pnpm format:files:check on every changed file passes)
  • pnpm typecheck (not run repo-wide; pnpm typecheck:files on runtime.ts, the test and the .tsrx fixture passes)
  • pnpm test (not run whole; see below)
  • targeted tests:
    • New packages/octane/tests/hydration/mismatch-empty-list.test.ts, for dev and prod compiles. Cases: server-empty list with no @empty; server @empty arm; server rendered fewer (non-zero) items, which keeps its per-item report; a pending lazy() sibling replaying the root and a @try boundary; a dormant <Hydrate> boundary whose list filled before activation, which rebuilds without reporting. Each asserts the final DOM, that the server's <i> is adopted, the onRecoverableError calls, and the exact diagnostic list (none in prod).
    • On the merged head, restoring main's inline branch fails 5 cases in each project. Passing quiet: false fails the @try replay in dev and prod. Before fix(hydration): report a suspended root's rebuilt mismatch once #1551 merged, always saying (@empty) failed the no-arm case. A root-level replay now rolls back to the server DOM and holds diagnostics until commit, so only the @try replay reaches the rebuilt-range check.
    • On the merged head, the new file plus mismatch-populated-list, mismatch-structural, mismatch-list-hole, emptyfor-hydrate, for-hydrate and both root-suspended-* suites pass in octane and octane-prod: 864 tests.
    • Before the merges, vitest --project octane --project octane-prod passed 36,047 tests. Load-only 5s timeouts in hmr.test.ts, behavior-root.test.ts and hydration-ssr-diagnostics.test.ts pass in isolation. The full suite was not re-run locally after the merges; CI covers it.
  • Bundle (benchmarks/bundle-size/run-minimal.mjs, current main vs this branch before the last main merge): hydrate-root and deferred-hydration +6 B raw and 4–7 B smaller gzipped; cli-spa-starter 10 B raw and 12 B gzip smaller; every other scenario unchanged. Brotli moves by up to ±54 B where raw barely changes. Before the shared method this was +85 B raw on hydrating bundles, which is what the earlier PR bench comment measured.
  • On discardListArm, dropping the rebuilt-range check fails the @try replay in both mismatch-empty-list and mismatch-populated-list (dev and prod). Always saying (@empty) fails the no-arm cases. After the last main merge, the list suites, mismatch-structural, mismatch-list-hole, emptyfor-hydrate, for-hydrate and root-suspended-clone-mismatch pass in both projects (752 tests), and pnpm typecheck:files passes.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches core @for hydration reconciliation and when structural mismatches are reported or suppressed during suspended/dormant boundary retries.

Overview
Fixes hydration @for mismatches when the server rendered no list items but the client has items: the client now emits one structural diagnostic and recoverable error at the list site, instead of duplicate warnings (including a misleading (@empty) label when the list has no @empty arm).

Introduces discardListArm on the hydration capability to handle both arm swaps (server populated / client @empty, and server empty / client items) through the shared discard path—recording rebuilt ranges, journaling for suspended retries, and suppressing repeat reports on replay. forBlock calls this helper instead of inline discard/warn/remove; discardPopulatedList is removed.

Dev messages distinguish an empty list from an empty list (@empty) based on whether the server actually rendered @empty content. Adds mismatch-empty-list hydration tests (no @empty, real @empty, partial server items, lazy/@try replay, dormant <Hydrate>) plus an octane patch changeset.

Reviewed by Cursor Bugbot for commit 8db950e. Bugbot is set up for automated code reviews on this repo. Configure here.

…tems

When the server rendered an `@for` with no items and the client has
items, forBlock warned that the server rendered "an empty list (@empty)"
even when the list has no `@empty` arm, and then the first item's
fewer-items recovery reported "another list item" for the same
mismatch. A pending sibling that replayed the attempt logged the list
warning a third time, because that warning bypassed the record of
ranges an earlier attempt rebuilt.

forBlock now discards the server's empty arm through
HydrationCapability.discardEmptyList, which reports once at the list's
own site and records the range as rebuilt, so the items, and any
replayed attempt, rebuild quietly. The diagnostic names `@empty` only
when the server left that arm's content in the range.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 2, 2026
@trueadm
trueadm marked this pull request as ready for review October 2, 2026 07:36
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 9 value(s) increased
  • 🔴 bundle-reachability: 3 value(s) increased

Compares 203be41eb with 66f1a29bd on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample also moving beyond that margin. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

All 20 timed operations (20 within noise)
target operation base head Δ noise
octane-tsrx run 4.65 4.25 −8.6% ±40% ⚪ within noise
octane-tsrx replace 10.76 9.99 −7.2% ±44% ⚪ within noise
octane-tsrx add 4.18 4.34 +3.8% ±23% ⚪ within noise
octane-tsrx update 0.52 0.61 +17.3% ±43% ⚪ within noise
octane-tsrx select 0.26 0.28 +7.7% ±59% ⚪ within noise
octane-tsrx swap 0.57 0.53 −7.0% ±32% ⚪ within noise
octane-tsrx remove 0.61 0.55 −9.8% ±50% ⚪ within noise
octane-tsrx runlots 40.00 38.24 −4.4% ±28% ⚪ within noise
octane-tsrx select_lots 0.33 0.31 −6.1% ±42% ⚪ within noise
octane-tsrx clear 52.67 53.49 +1.6% ±16% ⚪ within noise
octane-jsx run 5.75 4.78 −16.9% ±43% ⚪ within noise
octane-jsx replace 11.87 9.77 −17.7% ±34% ⚪ within noise
octane-jsx add 4.21 4.31 +2.4% ±35% ⚪ within noise
octane-jsx update 0.86 0.91 +5.8% ±50% ⚪ within noise
octane-jsx select 0.73 0.60 −17.8% ±38% ⚪ within noise
octane-jsx swap 0.82 1.00 +22.0% ±36% ⚪ within noise
octane-jsx remove 0.98 1.09 +11.2% ±53% ⚪ within noise
octane-jsx runlots 39.02 37.00 −5.2% ±33% ⚪ within noise
octane-jsx select_lots 3.77 3.17 −15.9% ±47% ⚪ within noise
octane-jsx clear 58.87 58.08 −1.3% ±27% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 126,474 126,436 −38 (−0.0%) 🟢
octane-tsrx js_gzip 41,859 41,827 −32 (−0.1%) 🟢
octane-tsrx js_brotli 36,945 36,854 −91 (−0.2%) 🟢
octane-tsrx app_brotli 2,227 2,226 −1 (−0.0%) 🟢
octane-tsrx fw_raw 118,962 118,924 −38 (−0.0%) 🟢
octane-tsrx fw_gzip 39,296 39,264 −32 (−0.1%) 🟢
octane-tsrx fw_brotli 34,718 34,628 −90 (−0.3%) 🟢
octane-tsrx todo_js_raw 140,880 140,842 −38 (−0.0%) 🟢
octane-tsrx todo_js_gzip 46,515 46,493 −22 (−0.0%) 🟢
octane-tsrx todo_js_brotli 40,751 40,756 +5 (+0.0%) 🔴
octane-tsrx todo_app_gzip 2,477 2,476 −1 (−0.0%) 🟢
octane-tsrx todo_app_brotli 2,121 2,123 +2 (+0.1%) 🔴
octane-tsrx todo_fw_raw 135,770 135,732 −38 (−0.0%) 🟢
octane-tsrx todo_fw_gzip 44,038 44,017 −21 (−0.0%) 🟢
octane-tsrx todo_fw_brotli 38,630 38,633 +3 (+0.0%) 🔴
octane-tsrx chat_js_raw 140,125 140,087 −38 (−0.0%) 🟢
octane-tsrx chat_js_gzip 46,452 46,425 −27 (−0.1%) 🟢
octane-tsrx chat_js_brotli 40,779 40,799 +20 (+0.0%) 🔴
octane-tsrx chat_app_gzip 2,980 2,977 −3 (−0.1%) 🟢
octane-tsrx chat_app_brotli 2,633 2,641 +8 (+0.3%) 🔴
octane-tsrx chat_fw_raw 133,472 133,434 −38 (−0.0%) 🟢
octane-tsrx chat_fw_gzip 43,472 43,448 −24 (−0.1%) 🟢
octane-tsrx chat_fw_brotli 38,146 38,158 +12 (+0.0%) 🔴
octane-tsrx weather_js_raw 176,366 176,328 −38 (−0.0%) 🟢
octane-tsrx weather_js_gzip 57,621 57,604 −17 (−0.0%) 🟢
octane-tsrx weather_js_brotli 50,073 50,142 +69 (+0.1%) 🔴
octane-tsrx weather_app_brotli 7,591 7,606 +15 (+0.2%) 🔴
octane-tsrx weather_fw_raw 149,631 149,593 −38 (−0.0%) 🟢
octane-tsrx weather_fw_gzip 48,578 48,561 −17 (−0.0%) 🟢
octane-tsrx weather_fw_brotli 42,482 42,536 +54 (+0.1%) 🔴

15 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 116,162 116,124 −38 (−0.0%) 🟢
cli-spa-starter gzip 39,219 39,198 −21 (−0.1%) 🟢
cli-spa-starter brotli 34,292 34,212 −80 (−0.2%) 🟢
hydrate-root raw 160,932 160,938 +6 (+0.0%) 🔴
hydrate-root gzip 51,580 51,574 −6 (−0.0%) 🟢
hydrate-root brotli 44,952 44,956 +4 (+0.0%) 🔴
deferred-hydration raw 223,310 223,316 +6 (+0.0%) 🔴
deferred-hydration gzip 71,029 71,022 −7 (−0.0%) 🟢
deferred-hydration brotli 61,320 61,285 −35 (−0.1%) 🟢

96 other measured values are unchanged.

CI job durations

  • 🟡 9 job(s) slower than every recent main run: test shard (Node 24, 1/4), heavy integration (browser - chromium), test shard (Node 24, 4/4), test shard (Node 24, 3/4), React parity shard (2/4), React parity shard (1/4), test shard (Node 24, 2/4), React parity shard (4/4), example apps (2/3)
  • 🟢 1 job(s) faster than every recent main run: typecheck checks

Compares the CI run for 8db950ef0 (run) with the last 5 successful main push runs. A job is only slower or faster outside the whole main range, by at least 10% and 15s. Job time excludes runner setup.

job main median main range this PR Δ
wall clock (first job start to last job end) 12m 31s 8m 50s–13m 11s 12m 58s +27s (+4%) ⚪ within noise
total job time 128m 13s 93m 59s–140m 37s 143m 49s +15m 36s (+12%) 🟡 slower
test shard (Node 24, 1/4) 7m 22s 6m 08s–9m 23s 11m 53s +4m 31s (+61%) 🟡 slower
heavy integration (browser - chromium) 7m 16s 6m 31s–9m 43s 11m 45s +4m 29s (+62%) 🟡 slower
test shard (Node 24, 4/4) 7m 41s 5m 50s–9m 27s 12m 04s +4m 23s (+57%) 🟡 slower
test shard (Node 24, 3/4) 6m 56s 5m 39s–8m 52s 10m 07s +3m 11s (+46%) 🟡 slower
React parity shard (2/4) 8m 07s 7m 36s–10m 02s 10m 33s +2m 26s (+30%) 🟡 slower
React parity shard (1/4) 8m 27s 6m 57s–10m 06s 10m 48s +2m 21s (+28%) 🟡 slower
test shard (Node 24, 2/4) 10m 01s 6m 26s–11m 56s 12m 20s +2m 19s (+23%) 🟡 slower
React parity shard (4/4) 9m 19s 7m 26s–10m 26s 11m 11s +1m 52s (+20%) 🟡 slower
example apps (2/3) 3m 25s 2m 44s–3m 36s 3m 50s +25s (+12%) 🟡 slower
typecheck checks 8m 08s 5m 37s–11m 11s 2m 13s −5m 55s (−73%) 🟢 faster
All 26 timed jobs
job main median main range this PR Δ
test shard (Node 24, 1/4) 7m 22s 6m 08s–9m 23s 11m 53s +4m 31s (+61%) 🟡 slower
heavy integration (browser - chromium) 7m 16s 6m 31s–9m 43s 11m 45s +4m 29s (+62%) 🟡 slower
test shard (Node 24, 4/4) 7m 41s 5m 50s–9m 27s 12m 04s +4m 23s (+57%) 🟡 slower
test shard (Node 24, 3/4) 6m 56s 5m 39s–8m 52s 10m 07s +3m 11s (+46%) 🟡 slower
heavy integration (package builds, eval corpus, runtime loaders, Astro) 3m 14s 2m 45s–5m 54s 5m 49s +2m 35s (+80%) ⚪ within noise
lint checks 5m 56s 4m 49s–9m 00s 8m 29s +2m 33s (+43%) ⚪ within noise
React parity shard (2/4) 8m 07s 7m 36s–10m 02s 10m 33s +2m 26s (+30%) 🟡 slower
React parity shard (1/4) 8m 27s 6m 57s–10m 06s 10m 48s +2m 21s (+28%) 🟡 slower
test shard (Node 24, 2/4) 10m 01s 6m 26s–11m 56s 12m 20s +2m 19s (+23%) 🟡 slower
React parity shard (4/4) 9m 19s 7m 26s–10m 26s 11m 11s +1m 52s (+20%) 🟡 slower
website integration suite 4m 44s 4m 40s–6m 30s 6m 02s +1m 18s (+27%) ⚪ within noise
React parity shard (3/4) 10m 02s 7m 10s–11m 26s 10m 31s +29s (+5%) ⚪ within noise
example apps (2/3) 3m 25s 2m 44s–3m 36s 3m 50s +25s (+12%) 🟡 slower
validate publishable packages 3m 58s 3m 25s–6m 22s 4m 10s +12s (+5%) ⚪ within noise
classify changeset release 13s 12s–14s 15s +2s (+15%) ⚪ within noise
example apps (3/3) 3m 29s 2m 36s–3m 46s 3m 31s +2s (+1%) ⚪ within noise
React parity checks 12s 11s–14s 13s +1s (+8%) ⚪ within noise
typecheck 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
examples 3s 3s–3s 3s ±0s (±0%) ⚪ within noise
lint 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
CI provenance 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
test (24) 4s 3s–4s 2s −2s (−50%) ⚪ within noise
example apps (1/3) 3m 28s 2m 44s–4m 09s 3m 16s −12s (−6%) ⚪ within noise
Lynx compatibility 1m 57s 1m 16s–2m 59s 1m 40s −17s (−15%) ⚪ within noise
Three compatibility 3m 17s 2m 24s–3m 26s 2m 55s −22s (−11%) ⚪ within noise
typecheck checks 8m 08s 5m 37s–11m 11s 2m 13s −5m 55s (−73%) 🟢 faster

trueadm and others added 3 commits October 2, 2026 13:25
…ion-report

# Conflicts:
#	packages/octane/src/runtime.ts
A root's suspended hydrating attempt now rolls back to the server DOM
and holds its diagnostics until commit, so a root-level replay no
longer reaches the record of ranges an earlier attempt rebuilt. A
@Try boundary's suspended attempt keeps what it built, so its replay
still does: run the replay case at both levels.

Also cover a dormant boundary whose list filled before activation,
which rebuilds the list without reporting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm and others added 4 commits October 2, 2026 13:57
discardEmptyList and main's discardPopulatedList made the same discard
call and differed only in their development wording. Fold them into
discardListArm, which takes which arm the server rendered. Production
hydrating bundles carry one method instead of two: against main,
hydrate-root goes from +85 to +6 raw bytes and -4 gzip bytes, and the
CLI starter is 10 raw bytes smaller.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion-report

# Conflicts:
#	packages/octane/src/runtime.ts
Since #1555, main already reports a server-empty list once, including
when an attempt retries, and its changeset says so. What this branch
still changes for users is the wording when the list has no @empty arm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trueadm
trueadm merged commit 21c3bfe into main Oct 2, 2026
31 checks passed
@trueadm
trueadm deleted the fix/empty-list-hydration-report branch October 2, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant