Repository navigation
fix(octane): discard server text an only-child hole's element value cannot adopt - #1430
Merged
Merged
Conversation
…annot adopt
A renderable `{expr}` hole that is its host's only child serializes a
primitive as the host's bare text and frames an element, a component, or a
list in a `<!--[-->…<!--]-->` range. When the server rendered text but the
client value is one of those, childTextHole pointed the cursor at that text
and called childSlot. In the root component, childSlot's root-return branch
abandoned hydration for the rest of the root, so a later only-child hole
rendered its text twice and the dev warning blamed "a renderable root". In
a nested component the value mounted beside the server text unreported.
HydrationCapability.hydrateOnlyChild now adopts the server's range when
there is one. Otherwise it discards the host's server content, reports the
recovery once with the hole's source location, and builds the value as a
client mount would under suspended hydration, so the rest of the root keeps
hydrating. A textarea keeps its server text as its default value, and a
dormant boundary whose captures changed repairs the hole silently. The
first node the hole builds is remembered across Suspense retry attempts,
which run under a new capability, so a value that suspends is reported and
built once. The childSlot call is passed in as a callback: naming it from
the hydration class would retain the whole child-slot graph in every
hydrating bundle.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 29, 2026 21:41
…2a98d # Conflicts: # packages/octane/src/runtime.ts # packages/octane/tests/hydration/mismatch-structural.test.ts
4 of 5 tasks
trueadm
added a commit
that referenced
this pull request
Sep 29, 2026
HTML tag names are ASCII case-insensitive, and ssrHostElement folds a
descriptor textarea's children on the lowercased tag. The client compared
the authored type exactly, so `createElement('TEXTAREA', null, 'a', list)`
still reconciled its children as a keyed list and left range comments
inside the textarea. Both de-opt paths now share a case-insensitive check
that compares the string before any DOM read.
With main merged, the only-child hole tests from #1430 expected an element
value inside a textarea to render beside the server text. A textarea's
children are text on both sides now, so that case asserts the error on the
server and through onUncaughtError on the client, and the suspending-hole
fixture no longer puts an element in a textarea.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Sep 29, 2026
…ides (#1435) * fix(octane): render a textarea's children as one text value on both sides Textarea content is RCDATA: the HTML parser keeps markup and comments inside it as literal text. A textarea with more than one child compiled to a client template with `<!>` placeholders inside the textarea (a client-only mount threw reading `parentNode` of null) and a server frame such as `hello <!-- -->A`, so the pre-hydration value held the markers and hydration reported a mismatch or rebuilt the root. A textarea's children now fold into one text value. The compiler binds it as the host's only Text node through `textareaText` and the server serializes it markerless through `ssrTextareaText`. Descriptor textareas (createElement, stored JSX) and a children prop from a spread follow the same rule. Strings and numbers render, empty values render nothing, arrays and iterables join, and any other value throws error 336 on both sides. Markup or a template directive written inside a textarea is a compile error. Signal handles in a compiled textarea's holes stay live through one derived handle over the parts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(octane): update mixed children of a spread textarea after hydration The spread textarea default reset is fixed on main (#1432), so the spread cases now join the shared mount, hydrate and update matrix. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(octane): fold a de-opt textarea's children whatever its tag's case HTML tag names are ASCII case-insensitive, and ssrHostElement folds a descriptor textarea's children on the lowercased tag. The client compared the authored type exactly, so `createElement('TEXTAREA', null, 'a', list)` still reconciled its children as a keyed list and left range comments inside the textarea. Both de-opt paths now share a case-insensitive check that compares the string before any DOM read. With main merged, the only-child hole tests from #1430 expected an element value inside a textarea to render beside the server text. A textarea's children are text on both sides now, so that case asserts the error on the server and through onUncaughtError on the client, and the suspending-hole fixture no longer puts an element in a textarea. 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 a renderable
{expr}hole that is its host element's only child mishandled server text when the client value is an element, a component, or a list:Server
{kind:'text'}, hydrate{kind:'p'}:childTextHolepointed the cursor at the bare server text and calledchildSlot. Its root-return branch read that as a mismatched root and calledabandonRoot, so the later only-child hole rendered<b>tt</b>. The dev warning also blamed "a renderable root".<div>A<!----><p>A</p><!----></div>), and nothing reachedonRecoverableError. A list value warned twice but still didn't report.Fix:
HydrationCapability.hydrateOnlyChildinpackages/octane/src/runtime.ts.<!--[-->range, the slot adopts it, as before.onRecoverableError(code 51). In dev it warns with the hole'ssiteLoc. It then builds the value exactly as a client mount would, with hydration suspended for that slot, so the rest of the root keeps hydrating.<Hydrate>boundary whose props changed before it activated (staleServerValues): the hole is repaired without a report.htextdoes for missing text.Both lowerings reach this path: the plain one (
childTextHoleUpdate) and the signal one (bindSignalChildwithonlyChild). So do.tsrxand.tsx.Two things a reviewer should know
HydrationCapability, and by design it re-adopts the DOM the failed attempt left. Per-capability freshness can't tell that DOM apart from server content. Without handling this, a retry reported a second mismatch and duplicated the element inside a textarea. A lazily created module-levelWeakSetrecords the first node each build produces (in afinally, since a suspension throws out of the build), and a retry drops that node silently.childSlotcall is passed in as a callback. NamingchildSlotfrom the hydration class retained the whole child-slot graph in every hydrating bundle: hydrate-root grew by about 111 KB raw in a first draft.Validation
pnpm format:check(repo-wide): not run.pnpm format:files:checkis clean on every changed file.pnpm typecheck(repo-wide): not run.pnpm typecheck:filespasses forruntime.tsand the three fixtures. The test file shows only errors that already exist in untouched lines (untyped.map((c) => …)callbacks).pnpm test: the unsharded local run hits a V8 heap out-of-memory in the Vitest main process, a known limitation of this machine. I ran the CI shard config locally instead. Before the merge withmain, shard 2/4 passed. Shard 1/4 passed apart from twopackages/clitests that timed out at 5 s under load; both pass on their own (24/24). I stopped shards 3/4 and 4/4 to mergemain, so CI is the evidence for them.packages/octane/testsfile in theoctaneandoctane-prodprojects passes (1,231 files, 25,256 tests).tests/hydration/mismatch-structural.test.ts; 27 of them fail before the fix. They cover dev and prod compile, root and nested, element, component and list values, a matching value adopting silently, an empty server host, a textarea,.tsx,bindSignalChild, a dormant boundary, and a value that suspends.benchmarks/bundle-size/run-minimal.mjs, against the pre-change runtime): hydrate-root +429 B raw / +118 B gzip / +123 B brotli; deferred-hydration +429 / +100 / +59. The client-only scenarios (cli-spa-starter, root-static-local, hooks-state, suspense-transition) are byte-identical. The CI-enforced--budgetsset passes.Risk / follow-ups
childSlotcall, and the new branch runs only on a hydrating first render of an object-valued only-child hole.htext. React would report it. Worth a follow-up decision if the policy should tighten.hempty) has landed and is merged in here. Its method sits next tohydrateOnlyChild, and both suites pass together. The framed element→text work (discardUnadoptedText) is still in flight and touches the same area.<textarea>frame leak (<!--[-->A<!--]-->as literal text) is now fixed onmainby fix(octane): serialize a spread host's sole child unframed and keep textarea children live #1432.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 first-render hydration for a narrow but user-visible DOM mismatch path; behavior is well-tested but incorrect recovery previously corrupted roots or duplicated text.
Overview
Fixes hydration when a markerless only-child
{expr}hole was server-rendered as bare text but the client first renders an element, component, or list.HydrationCapability.hydrateOnlyChild(wired fromchildTextHoleon the hydrating object-value path) either adopts the server<!--[-->range as before, or strips stale server text, firesonRecoverableErroronce (dev warns at the hole’ssiteLoc), and mounts the client value without abandoning the rest of the root.HYDRATION_BUILT_CONTENTavoids double-report/duplicate DOM on suspense retries; textarea keeps server text as default value; dormant<Hydrate>withstaleServerValuesrepairs silently.Adds fixtures and a large
mismatch-structural.test.tssuite (dev/prod, root/nested, suspense, signals, TSX).Reviewed by Cursor Bugbot for commit 83a8242. Bugbot is set up for automated code reviews on this repo. Configure here.