Skip to content

fix(hydration): report a server-populated list rebuilt as @empty - #1559

Merged
trueadm merged 1 commit into
mainfrom
fix/populated-list-hydration-report
Oct 2, 2026
Merged

trueadm merged 1 commit into
mainfrom
fix/populated-list-hydration-report

Conversation

@trueadm

@trueadm trueadm commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Hydrating an @for with an @empty arm, when the server rendered items and the client has none, rebuilt the list correctly but only logged a development warning. onRecoverableError never fired, so production reported nothing for a structural rebuild. Every other structural list rebuild reports one (HydrationCapability.discard notes error 51; discardLeftoverItems notes 56).

The branch called hydration.warnStructural and removeRange directly, so it also bypassed:

  • staleServerValues: a dormant <Hydrate> boundary whose list emptied before it activated warned in development, although that difference is legitimate;
  • the HYDRATION_REBUILT memory: when a boundary attempt suspended on a pending sibling, the retry found the first attempt's @empty arm under the [f1 marker and reported the list again.

forBlock now calls a new HydrationCapability.discardPopulatedList(scope, slotKey, start, end), which routes through the private discard exactly as the other structural rebuilds do. That gives it the recoverable error (51), the staleServerValues gate, save() journaling for a suspended root attempt, presentationMiss() for a presentation takeover, and the HYDRATION_REBUILT memory for replays. discard's actual parameter now also accepts a description string, so the development diagnostic keeps its existing wording at the @for site. The check stays inside the mismatch branch, so the adoption path is unchanged.

This is the reverse direction of #1542 (server empty, client items). The discard signature hunk is byte-identical to #1542's, so this branch adds no conflict with it. #1542 currently conflicts with main on its own: main added hydration.save(domParent) to the server-empty branch, and discard now calls save itself, so that conflict resolves to discardEmptyList.

Validation

  • pnpm format:check (scoped pnpm format:files:check on the 4 changed files: clean)
  • pnpm typecheck (scoped pnpm typecheck:files on runtime.ts, the test, and the .tsrx fixture: clean)
  • pnpm test: not run whole. Full octane + octane-prod projects ran on the previous base under load average 60–140: 150 failures, 94 of them timeouts and the rest follow-on errors. Re-running the failing files on their own, then serially with raised timeouts, left one test hitting its own 15s deadline (behavior-root "attaches to existing DOM…", a static behavior root with no list), which then passed twice on its own.
  • targeted tests on this base: packages/octane/tests/hydration + for.test.ts + hydration.test.ts in octane and octane-prod: 234 files, 12,083 passed.
  • new tests/hydration/mismatch-populated-list.test.ts, dev and prod compiles: exactly one recoverable error, one dev diagnostic with the existing wording at the @for site, none in prod, final <i><b>none</b>ok</i> with <i> adopted; pending-lazy() replay at the root and inside a @try boundary each report once; the server @empty arm adopts without a report; a dormant boundary whose list emptied before activation reports nothing.
    • Pre-fix (this base): 7 of 10 red per project. The 3 green are the two adoption controls and the prod dormant case, which reported nothing before either.
    • Mutation: with the quiet flag forced to false, the @try replay case goes red in both compiles. The root replay case is covered by main's root-attempt rollback.

Bundle (node benchmarks/bundle-size/run-minimal.mjs, origin/main vs this branch): hydrate-root and deferred-hydration +79 raw / +27–41 gzip; cli-spa-starter +11 raw (the call site's method name); the other 32 scenarios are byte-identical. The production method body carries no diagnostic strings.

Risk / follow-ups

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 hydration mismatch handling for @for; behavior changes include production error reporting and presentation takeover (presentationMiss) on this discard path, though rendering outcome was already correct.

Overview
When the server rendered @for items but the client hydrates with an empty collection and builds the @empty arm, the client now reports that structural rebuild through onRecoverableError in production (not only a dev console warning). The @for path calls new discardPopulatedList, which reuses the same discard pipeline as other hydration mismatches—recoverable error 51, HYDRATION_REBUILT so a pending sibling replay does not double-report, and staleServerValues so a dormant <Hydrate> boundary that legitimately emptied before activation rebuilds quietly.

discard’s development diagnostic can describe the server side with a string (e.g. “a populated list”) instead of only a DOM node. Adoption when server and client both use @empty is unchanged.

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

Hydrating an @for with an @empty arm, when the server rendered items and
the client has none, discarded the server items and built @empty but only
logged a dev warning: onRecoverableError never fired, so production
reported nothing for a structural rebuild. The branch also bypassed the
HYDRATION_REBUILT replay memory (a pending sibling replay logged twice)
and staleServerValues (a dormant boundary whose list emptied before
activation warned in development).

Route it through HydrationCapability.discard via discardPopulatedList,
like every other structural list rebuild.

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 11:38
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

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

Compares 4ab33b6b1 with 569eac159 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 3.29 3.31 +0.6% ±5% ⚪ within noise
octane-tsrx replace 7.17 7.38 +2.9% ±27% ⚪ within noise
octane-tsrx add 3.50 3.50 −0.0% ±29% ⚪ within noise
octane-tsrx update 0.45 0.43 −4.4% ±45% ⚪ within noise
octane-tsrx select 0.20 0.20 −0.0% ±62% ⚪ within noise
octane-tsrx swap 0.40 0.37 −7.5% ±33% ⚪ within noise
octane-tsrx remove 0.41 0.40 −2.4% ±36% ⚪ within noise
octane-tsrx runlots 31.04 31.25 +0.7% ±14% ⚪ within noise
octane-tsrx select_lots 0.24 0.27 +12.5% ±66% ⚪ within noise
octane-tsrx clear 43.16 43.83 +1.6% ±10% ⚪ within noise
octane-jsx run 3.82 3.59 −6.0% ±17% ⚪ within noise
octane-jsx replace 8.40 7.72 −8.1% ±24% ⚪ within noise
octane-jsx add 3.31 3.17 −4.2% ±10% ⚪ within noise
octane-jsx update 0.67 0.59 −11.9% ±32% ⚪ within noise
octane-jsx select 0.48 0.37 −22.9% ±46% ⚪ within noise
octane-jsx swap 0.68 0.74 +8.8% ±39% ⚪ within noise
octane-jsx remove 0.63 0.63 +0.0% ±37% ⚪ within noise
octane-jsx runlots 30.31 28.66 −5.4% ±9% ⚪ within noise
octane-jsx select_lots 2.57 2.44 −5.1% ±27% ⚪ within noise
octane-jsx clear 45.19 43.47 −3.8% ±16% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 126,041 126,052 +11 (+0.0%) 🔴
octane-tsrx js_gzip 41,679 41,685 +6 (+0.0%) 🔴
octane-tsrx js_brotli 36,736 36,731 −5 (−0.0%) 🟢
octane-tsrx app_gzip 2,564 2,563 −1 (−0.0%) 🟢
octane-tsrx app_brotli 2,229 2,222 −7 (−0.3%) 🟢
octane-tsrx fw_raw 118,529 118,540 +11 (+0.0%) 🔴
octane-tsrx fw_gzip 39,115 39,122 +7 (+0.0%) 🔴
octane-tsrx fw_brotli 34,507 34,509 +2 (+0.0%) 🔴
octane-tsrx todo_js_raw 140,390 140,401 +11 (+0.0%) 🔴
octane-tsrx todo_js_gzip 46,312 46,327 +15 (+0.0%) 🔴
octane-tsrx todo_js_brotli 40,587 40,584 −3 (−0.0%) 🟢
octane-tsrx todo_fw_raw 135,280 135,291 +11 (+0.0%) 🔴
octane-tsrx todo_fw_gzip 43,836 43,851 +15 (+0.0%) 🔴
octane-tsrx todo_fw_brotli 38,469 38,466 −3 (−0.0%) 🟢
octane-tsrx chat_js_raw 139,635 139,646 +11 (+0.0%) 🔴
octane-tsrx chat_js_gzip 46,267 46,280 +13 (+0.0%) 🔴
octane-tsrx chat_js_brotli 40,657 40,616 −41 (−0.1%) 🟢
octane-tsrx chat_app_gzip 2,980 2,976 −4 (−0.1%) 🟢
octane-tsrx chat_app_brotli 2,637 2,634 −3 (−0.1%) 🟢
octane-tsrx chat_fw_raw 132,982 132,993 +11 (+0.0%) 🔴
octane-tsrx chat_fw_gzip 43,287 43,304 +17 (+0.0%) 🔴
octane-tsrx chat_fw_brotli 38,020 37,982 −38 (−0.1%) 🟢
octane-tsrx weather_js_raw 175,875 175,886 +11 (+0.0%) 🔴
octane-tsrx weather_js_gzip 57,415 57,427 +12 (+0.0%) 🔴
octane-tsrx weather_js_brotli 49,930 49,941 +11 (+0.0%) 🔴
octane-tsrx weather_app_brotli 7,602 7,606 +4 (+0.1%) 🔴
octane-tsrx weather_fw_raw 149,140 149,151 +11 (+0.0%) 🔴
octane-tsrx weather_fw_gzip 48,371 48,383 +12 (+0.0%) 🔴
octane-tsrx weather_fw_brotli 42,328 42,335 +7 (+0.0%) 🔴

16 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 115,850 115,861 +11 (+0.0%) 🔴
cli-spa-starter gzip 39,082 39,101 +19 (+0.0%) 🔴
cli-spa-starter brotli 34,120 34,179 +59 (+0.2%) 🔴
hydrate-root raw 159,641 159,720 +79 (+0.0%) 🔴
hydrate-root gzip 51,135 51,176 +41 (+0.1%) 🔴
hydrate-root brotli 44,604 44,637 +33 (+0.1%) 🔴
deferred-hydration raw 221,896 221,975 +79 (+0.0%) 🔴
deferred-hydration gzip 70,561 70,588 +27 (+0.0%) 🔴
deferred-hydration brotli 60,979 60,970 −9 (−0.0%) 🟢
binding-mantine-hooks-esbuild brotli 28,915 28,918 +3 (+0.0%) 🔴

95 other measured values are unchanged.

CI job durations

  • 🟡 1 job(s) slower than every recent main run: React parity shard (2/4)

Compares the CI run for 4fdcf560c (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) 13m 32s 11m 55s–15m 07s 13m 22s −10s (−1%) ⚪ within noise
total job time 149m 29s 134m 18s–156m 28s 140m 16s −9m 13s (−6%) ⚪ within noise
React parity shard (2/4) 10m 30s 9m 52s–11m 18s 11m 48s +1m 18s (+12%) 🟡 slower
All 26 timed jobs
job main median main range this PR Δ
React parity shard (2/4) 10m 30s 9m 52s–11m 18s 11m 48s +1m 18s (+12%) 🟡 slower
React parity shard (4/4) 11m 19s 10m 08s–12m 06s 12m 13s +54s (+8%) ⚪ within noise
lint checks 8m 01s 7m 46s–9m 37s 8m 32s +31s (+6%) ⚪ within noise
Three compatibility 2m 44s 2m 38s–3m 48s 3m 06s +22s (+13%) ⚪ within noise
Lynx compatibility 1m 32s 1m 29s–2m 04s 1m 36s +4s (+4%) ⚪ within noise
validate publishable packages 4m 16s 3m 51s–5m 00s 4m 20s +4s (+2%) ⚪ within noise
example apps (1/3) 3m 12s 3m 06s–3m 19s 3m 16s +4s (+2%) ⚪ within noise
examples 3s 3s–4s 4s +1s (+33%) ⚪ within noise
classify changeset release 13s 13s–15s 13s ±0s (±0%) ⚪ within noise
typecheck 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
lint 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
React parity checks 11s 10s–12s 11s ±0s (±0%) ⚪ within noise
test (24) 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
CI provenance 3s 3s–4s 3s ±0s (±0%) ⚪ within noise
test shard (Node 24, 2/4) 12m 09s 10m 38s–14m 29s 12m 05s −4s (−1%) ⚪ within noise
example apps (2/3) 3m 43s 3m 38s–3m 49s 3m 36s −7s (−3%) ⚪ within noise
example apps (3/3) 3m 38s 3m 19s–3m 41s 3m 28s −10s (−5%) ⚪ within noise
test shard (Node 24, 1/4) 11m 23s 10m 36s–13m 13s 11m 09s −14s (−2%) ⚪ within noise
website integration suite 5m 56s 5m 44s–7m 00s 5m 40s −16s (−4%) ⚪ within noise
heavy integration (package builds, eval corpus, runtime loaders, Astro) 5m 43s 5m 27s–5m 45s 5m 20s −23s (−7%) ⚪ within noise
test shard (Node 24, 3/4) 10m 02s 9m 24s–10m 50s 9m 35s −27s (−4%) ⚪ within noise
heavy integration (browser - chromium) 12m 12s 10m 58s–12m 54s 11m 37s −35s (−5%) ⚪ within noise
test shard (Node 24, 4/4) 11m 06s 10m 21s–13m 56s 10m 20s −46s (−7%) ⚪ within noise
React parity shard (1/4) 10m 55s 10m 45s–12m 00s 10m 05s −50s (−8%) ⚪ within noise
React parity shard (3/4) 10m 36s 10m 08s–12m 02s 9m 43s −53s (−8%) ⚪ within noise
typecheck checks 8m 20s 1m 56s–9m 11s 2m 07s −6m 13s (−75%) ⚪ within noise

@trueadm
trueadm merged commit cb71034 into main Oct 2, 2026
53 checks passed
@trueadm
trueadm deleted the fix/populated-list-hydration-report branch October 2, 2026 12:06
trueadm added a commit that referenced this pull request Oct 2, 2026
main now reports a server-populated list rebuilt as @empty through
discardPopulatedList (#1559), so this PR no longer claims that direction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 2, 2026
…1555)

* fix(hydration): report discarded server ranges to onRecoverableError

Several structural hydration recoveries discarded server content and
rebuilt it on the client without ever calling hydrateRoot's
onRecoverableError, in development or production:

- an @if arm only the server rendered (empty client branch);
- a branch range the server encoded as something else, such as a keyed
  list from another version of the page;
- a list whose server arm (items or @empty) differs from the client's;
- a runtime host element whose server content cannot be the client's.

HydrationCapability.reportRebuiltRange reports the range once: a
suspended boundary's next attempt finds the earlier attempt's content
before the same end, and a list's open marker still names the server's
arm, so it would otherwise report the swap again. Captures that changed
before a dormant boundary activated still recover without reporting or
warning, as the sibling recovery sites do.

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

* test(hydration): report a discarded range once from the root attempt that commits

The merge with main adopts its speculative root hydration attempt: a root
without a boundary keeps the server content while its hydrating attempt is
suspended, and only the attempt that commits reports. reportRebuiltRange
now marks the range end through remember, like discard, so the rollback
forgets the mark with the DOM it described and the committing retry
reports the recovery once instead of never.

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

* docs(changeset): scope the recoverable-range changeset to this PR

main now reports a server-populated list rebuilt as @empty through
discardPopulatedList (#1559), so this PR no longer claims that direction.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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