Repository navigation
fix(hydration): report a server-empty list once when the client has items - #1542
Merged
Merged
Conversation
…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]>
trueadm
marked this pull request as ready for review
October 2, 2026 07:36
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
15 other measured values are unchanged. Public-import reachability bundles (bytes)
96 other measured values are unchanged. CI job durations
Compares the CI run for
All 26 timed jobs
|
This was referenced Oct 2, 2026
…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]>
2 of 5 tasks
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]>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Hydrating an
@forthat 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:
the client expected a populated list but the server rendered an empty list (@empty). This was misleading when the list has no@emptyarm.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 (alazy()child) held the attempt and it replayed, line 1 fired a third time. That warning calledwarnStructuraldirectly, 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 renderedan empty list (@empty)when the list has no@emptyarm. Against current main, this PR:forBlock's server-empty branch, and fix(hydration): report a server-populated list rebuilt as @empty #1559'sdiscardPopulatedList, with one shareddiscardListArm, which makes the bundle changes below; andChanges
HydrationCapability.discardListArm(inpackages/octane/src/runtime.ts) handles a list whose client renders the other arm from the server, in both directions. It replacesdiscardPopulatedListfrom fix(hydration): report a server-populated list rebuilt as @empty #1559 (server items, client@empty) and adds this PR's case (server empty, client items). Both go through the privatediscard, which records one recoverable error, warns in dev, journals the list's parent withsave(so a suspended root attempt still rolls back, fix(hydration): report a suspended root's rebuilt mismatch once #1551), removes what the server rendered, and remembers the range as rebuilt. Each client item'sdiscardItemsand any replayed attempt then rebuild quietly.forBlock's server-empty branch calls it instead of saving, reporting throughreportRebuiltRange, warning and removing inline (main after fix(hydration): report discarded server ranges to onRecoverableError #1555). The branch conditions are unchanged, so the normal adoption path does no extra work.an empty list, andan empty list (@empty)only when the server left@emptycontent in the range. The populated direction keeps fix(hydration): report a server-populated list rebuilt as @empty #1559's wording.octanepatch.Validation
pnpm format:check(not run repo-wide;pnpm format:files:checkon every changed file passes)pnpm typecheck(not run repo-wide;pnpm typecheck:filesonruntime.ts, the test and the.tsrxfixture passes)pnpm test(not run whole; see below)packages/octane/tests/hydration/mismatch-empty-list.test.ts, for dev and prod compiles. Cases: server-empty list with no@empty; server@emptyarm; server rendered fewer (non-zero) items, which keeps its per-item report; a pendinglazy()sibling replaying the root and a@tryboundary; 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, theonRecoverableErrorcalls, and the exact diagnostic list (none in prod).quiet: falsefails the@tryreplay 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@tryreplay reaches the rebuilt-range check.mismatch-populated-list,mismatch-structural,mismatch-list-hole,emptyfor-hydrate,for-hydrateand bothroot-suspended-*suites pass inoctaneandoctane-prod: 864 tests.vitest --project octane --project octane-prodpassed 36,047 tests. Load-only 5s timeouts inhmr.test.ts,behavior-root.test.tsandhydration-ssr-diagnostics.test.tspass in isolation. The full suite was not re-run locally after the merges; CI covers it.benchmarks/bundle-size/run-minimal.mjs, current main vs this branch before the last main merge):hydrate-rootanddeferred-hydration+6 B raw and 4–7 B smaller gzipped;cli-spa-starter10 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.discardListArm, dropping the rebuilt-range check fails the@tryreplay in bothmismatch-empty-listandmismatch-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-hydrateandroot-suspended-clone-mismatchpass in both projects (752 tests), andpnpm typecheck:filespasses.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core
@forhydration reconciliation and when structural mismatches are reported or suppressed during suspended/dormant boundary retries.Overview
Fixes hydration
@formismatches 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@emptyarm).Introduces
discardListArmon the hydration capability to handle both arm swaps (server populated / client@empty, and server empty / client items) through the shareddiscardpath—recording rebuilt ranges, journaling for suspended retries, and suppressing repeat reports on replay.forBlockcalls this helper instead of inline discard/warn/remove;discardPopulatedListis removed.Dev messages distinguish
an empty listfroman empty list (@empty)based on whether the server actually rendered@emptycontent. Addsmismatch-empty-listhydration tests (no@empty, real@empty, partial server items, lazy/@tryreplay, dormant<Hydrate>) plus anoctanepatch changeset.Reviewed by Cursor Bugbot for commit 8db950e. Bugbot is set up for automated code reviews on this repo. Configure here.