Repository navigation
fix(hydration): report a server-populated list rebuilt as @empty - #1559
Merged
Merged
Conversation
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]>
trueadm
marked this pull request as ready for review
October 2, 2026 11:38
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)
16 other measured values are unchanged. Public-import reachability bundles (bytes)
95 other measured values are unchanged. CI job durations
Compares the CI run for
All 26 timed jobs
|
2 of 5 tasks
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]>
2 of 5 tasks
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]>
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
@forwith an@emptyarm, when the server rendered items and the client has none, rebuilt the list correctly but only logged a development warning.onRecoverableErrornever fired, so production reported nothing for a structural rebuild. Every other structural list rebuild reports one (HydrationCapability.discardnotes error 51;discardLeftoverItemsnotes 56).The branch called
hydration.warnStructuralandremoveRangedirectly, so it also bypassed:staleServerValues: a dormant<Hydrate>boundary whose list emptied before it activated warned in development, although that difference is legitimate;HYDRATION_REBUILTmemory: when a boundary attempt suspended on a pending sibling, the retry found the first attempt's@emptyarm under the[f1marker and reported the list again.forBlocknow calls a newHydrationCapability.discardPopulatedList(scope, slotKey, start, end), which routes through the privatediscardexactly as the other structural rebuilds do. That gives it the recoverable error (51), thestaleServerValuesgate,save()journaling for a suspended root attempt,presentationMiss()for a presentation takeover, and theHYDRATION_REBUILTmemory for replays.discard'sactualparameter now also accepts a description string, so the development diagnostic keeps its existing wording at the@forsite. 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
discardsignature hunk is byte-identical to #1542's, so this branch adds no conflict with it. #1542 currently conflicts with main on its own: main addedhydration.save(domParent)to the server-empty branch, anddiscardnow callssaveitself, so that conflict resolves todiscardEmptyList.Validation
pnpm format:check(scopedpnpm format:files:checkon the 4 changed files: clean)pnpm typecheck(scopedpnpm typecheck:fileson runtime.ts, the test, and the.tsrxfixture: clean)pnpm test: not run whole. Fulloctane+octane-prodprojects 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.packages/octane/tests/hydration+for.test.ts+hydration.test.tsinoctaneandoctane-prod: 234 files, 12,083 passed.tests/hydration/mismatch-populated-list.test.ts, dev and prod compiles: exactly one recoverable error, one dev diagnostic with the existing wording at the@forsite, none in prod, final<i><b>none</b>ok</i>with<i>adopted; pending-lazy()replay at the root and inside a@tryboundary each report once; the server@emptyarm adopts without a report; a dormant boundary whose list emptied before activation reports nothing.false, the@tryreplay 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/mainvs this branch):hydrate-rootanddeferred-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
presentationMiss) instead of rebuilding in place. Every other structural discard already does this.discardEmptyListanddiscardPopulatedListcould fold into one method to save a few dozen bytes.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 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
@foritems but the client hydrates with an empty collection and builds the@emptyarm, the client now reports that structural rebuild throughonRecoverableErrorin production (not only a dev console warning). The@forpath calls newdiscardPopulatedList, which reuses the samediscardpipeline as other hydration mismatches—recoverable error 51,HYDRATION_REBUILTso a pending sibling replay does not double-report, andstaleServerValuesso 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@emptyis unchanged.Reviewed by Cursor Bugbot for commit 4fdcf56. Bugbot is set up for automated code reviews on this repo. Configure here.