Repository navigation
fix: preserve server content during document hydration - #1324
Closed
domgan-oai wants to merge 2 commits into
Closed
domgan-oai wants to merge 2 commits into
domgan-oai wants to merge 2 commits into
Conversation
domgan-oai
marked this pull request as ready for review
September 25, 2026 22:05
domgan-oai
marked this pull request as draft
September 25, 2026 22:06
domgan-oai
marked this pull request as ready for review
September 25, 2026 22:07
This was referenced Sep 25, 2026
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
Fixes #1321. A TanStack Start document shell can place a head portal alongside the selected body hydration owner. The client now adopts the server route in that list, keeping the original interactive DOM instead of duplicating it.
Why
The selected container does not contain server list frames for the shell's logical siblings. Treating them as ordinary server list items consumes the body's hydration cursor before the owner reaches it.
Changes
Validation
pnpm format:check(with the interim upstream-source formatter described below)pnpm typecheck(the last full attempt stopped at a missing MDX declaration after passing through Shadcn; the isolated MDX check passed after restoring the missing link, but the full command has not been rerun)pnpm test(Three and Visx prechecks pass; the full browser-capable run was interrupted after Jotai and Motion pristine failures and Mantine Hooks collection failures. The underlying causes and final totals remain undetermined.)pnpm sync; independent complexity review; local production-build JSDOM component-list timing comparison (no observed regression in this sample).The focused checks and sync used a task-local interim toolchain: the OXC archives matched the lockfile hashes; the cached core source and a source-built runtime helper matched the upstream release tag, but the helper archive was not byte-identical to the published artifact. The formatter, TypeScript plugin, React compiler, and React runtime were also sourced from their upstream tag; their source-built archives were not verified byte-identical to the locked published artifacts. The integration test uses real Start and Router components in JSDOM; it does not exercise serialized router-state transport or a physical browser. Full-suite attempts used Node 26, while CI uses Node 24; Node 26 emitted localStorage warnings, but their relationship to the failures is unverified.
Risk / follow-ups
Pre-existing limitations remain when a boundary suspends before visiting a later owner, when single-owner passthrough hydration encounters an unframed single root, when renderer styles are interspersed among multiple server roots, and when an error boundary resets after fallback. These were reproduced independently on the original runtime and are outside this fix.
Provenance
agent-authored)Codex task · host:
com-79386Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Touches core client hydration and keyed list mounting used when boundary components return multiple roots; incorrect cursor or range handling can cause DOM duplication, lost interactivity, or SSR mismatches in document-style apps.
Overview
Fixes hydration when a document shell (e.g. TanStack Start) renders portal siblings (head/scripts) next to a selected body owner whose server HTML lives alone in the hydration root—without server list frames for those logical siblings.
The runtime adds a passthrough list path: while
hydration.passthroughRangesis active on a borrowed@forslot, it mints per-item client comment ranges, routes first fill throughmountPassthroughListItem, and advances the hydration cursor so the owner adopts existing nodes instead of duplicating them. Related updates cover marker placement, rollback on mount errors, suspense/error fallbacks (mountPassthroughCatch/ pending try), and cursor handoff after the list consumes the owner.Tests: expanded
range-boundaryhydration fixtures and coverage (nested lists, reorder, empty server HTML, Suspense, ErrorBoundary); new TanStack Startdocument-hydrationtest (StartServer→hydrateRoot/StartClient). Evalmanifest.jsonlgrader digests refresh from the Start vitest plugin change; changeset marks an octane patch.Reviewed by Cursor Bugbot for commit f93b148. Bugbot is set up for automated code reviews on this repo. Configure here.