Repository navigation
fix: preserve server content during document hydration - #1331
Merged
Merged
Conversation
…t hydration - Mark a client-only passthrough list item's content fresh so finishRoot() does not sweep it as stale server remainder. - End passthrough in childSlot when it reaches the selected owner, matching componentSlot, so a keyed owner item hands off the server cursor. - Resolve extensionless fixture imports by exact filename: esbuild matches directory entries case-insensitively, so `./link` picked `Link.tsrx` (ENOENT on Linux). - Bind the catch fallback parent locally for the staged-DOM lint. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 26, 2026 11:50
5 tasks done
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
Replaces #1324, whose head lives on an org-owned fork that maintainers cannot push to. It carries that PR's commits unchanged, plus a follow-up commit fixing its CI failures and two hydration defects found in review.
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
finishRoot()no longer sweeps it as stale server remainder. Before this, a shell returning a bare array with a host sibling after the owner lost that sibling and later crashed on reorder (moveBlockBeforeon a detached marker).childSlotends passthrough when it reaches the owner, ascomponentSlotalready did. An owner that is itself a keyed list item previously left passthrough on, so a later sibling suspending insideSuspenseretried after hydration and duplicated the server content (the [tanstack-start] Initial document hydration duplicates the route and leaves the SSR button inert (Octane 0.5.0) #1321 symptom).scripts/react-parity/server-fixtures.mjs) resolves extensionless relative imports by exact filename. esbuild matches directory entries case-insensitively, so./linkresolved toLink.tsrxahead oflink.ts: wrong on macOS andENOENTon Linux CI.mountPassthroughCatchbinds its parent to a local so the staged-DOM lint recognises the guardedlastChildread.Validation
range-boundarycases (dev and prod). They cover a bare-array shell with client-only host content, suspending at the root and withinSuspense, and a directly keyed owner item. All fail on the previous head and pass now; reverting either runtime fix individually turns its cases red.packages/octane/tests/hydration,packages/tanstack-start/tests,packages/tanstack-router/tests: 178 files / 2478 tests pass.ci:workflow:test(includingcheck-staged-dom),test:markers:check,changeset:check,error-codes:check,tsrx-decls:check,rules:check,packages:inventory:check,context:budget:check,redact-audit:check.pnpm sync(no generated changes),pnpm format:files:check, scopedtypecheck:files(tsrx-tsc).different-path-casewarning for./linkwhen bundling the Start fixture.vitest.ci-sharded.config.js, 4/4 shards, CI exclusions): 2,256 files / 31,788 tests pass. An unsharded localpnpm testran out of heap in the Vitest main process (4 GB) without any test failures.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)Original commits: Codex task · host:
com-79386🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Touches core hydration and list mounting in
runtime.ts, which can affect SSR adoption, suspense/error recovery, and keyed updates across apps using range boundaries.Overview
Fixes document-shell hydration when the client tree is a passthrough list/array with portal siblings and a selected body hydration owner (e.g. TanStack Start
StartClientbeside head content). The server HTML only contains the owner’s range, so list reconciliation no longer treats shell siblings as normal server list frames and steal the hydration cursor before the owner runs.The runtime now mounts passthrough list items with bounded client comment ranges, smarter anchor insertion (including borrowed lists and renderer style sidecars), and advances the hydration cursor after the list. Reaching a non-transparent owner through a value slot ends passthrough like
componentSlotalready did. Try/catch paths can mark fresh fallback DOM during passthrough handoff, with rollback on mount failure.Adds broad hydration regressions (
range-boundary), a TanStack Start SSR→hydrate integration test, a changeset patch, refreshed eval grader digests, and a server-fixture resolver tweak so extensionless imports prefer exact filenames over case-insensitive directory matches on Linux CI.Reviewed by Cursor Bugbot for commit 23972ff. Bugbot is set up for automated code reviews on this repo. Configure here.