Repository navigation
Make production hydration template-free on the happy path - #218
Merged
Merged
Conversation
Prod hydration now validates an adoption root by nodeType + localName only (React parity: prod React doesn't attribute-validate either), answered straight off the template's source string via a lazily-scanned root descriptor — so adopting server DOM never parses the template. Parsing happens only on the cold paths: mismatch recovery, client-side mounts while hydration is suspended, and the once-per-root fragment claim. Dev keeps the full deep walk + attribute compare + warnings, build-time stripped behind NODE_ENV. Tag-level and text-level mismatches still detect and recover in prod; same-tag branches differing only in static attributes are no longer detected there (documented narrowing in differences-from-react.md). Hydration also never clones template DOM — that was already true (adoption returns the server cursor) and is now pinned by a Node.prototype.cloneNode spy. news bench (prod, headless Chromium, 20 iters): hydrate 1.78 -> 1.54 ms (Svelte 1.50 in the same run), correctness gates green. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The compiler namespaces `image` roots as SVG (SVG_ONLY_TAGS), where the parser keeps `image` and the exact compare already matches — so the HTML-parser rewrite arm was unreachable for compiled templates, and on an SVG-`image`/HTML-`img` branch swap it would wrongly adopt instead of recovering. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cd32300. Configure here.
Same fail-open shape as the image->img arm: for every VALID pairing the parser canonicalizes the server localName to the source spelling (HTML/ MathML lowercase, SVG camelCase restored by the case-adjustment table), so the exact compare suffices. The toLowerCase fallback only "matched" invalid markup — an SVG-only camelCase root misplaced in an HTML parent parses as a lowercased HTMLUnknownElement — where prod would then adopt the wrong-namespace node while the pre-narrowing parsed-template compare (and dev today) mismatches and rebuilds. Exact-only fails safe. Co-Authored-By: Claude Fable 5 <[email protected]>
mrdiyorbek-juraev
added a commit
to mrdiyorbek-juraev/octane
that referenced
this pull request
Jul 22, 2026
Brings in 12 upstream commits, including the shared TSRX semantic analysis across client/server/universal/Volar compilation (octanejs#230), the deferred hydration fix (octanejs#229), Lynx Milestone 7 worklets (octanejs#227), template-free production hydration (octanejs#218), and the dependency/TSRX toolchain refresh (octanejs#223) with the release that followed it. Two conflicts, both in generated files, resolved by taking upstream and regenerating from the merged tree: - docs/packages.md — 47 publishable packages upstream, 48 here. Verified as a strict superset: every package upstream lists is still present, and the only additions are `@octanejs/cmdk` and `packages/cmdk`. - packages/octane-evals/.../manifest.jsonl — all 19 task ids match upstream, and a field-level comparison shows only environment.overlayLockfileHash and grader.graderDigest differ. No prompt, policy, reference or grader command changed, so task semantics are untouched; both fields derive from the lockfile, which necessarily moved. pnpm install also rewrote pnpm-workspace.yaml as a side effect — it flattened upstream's `*esrap_common` YAML anchor and appended [email protected] to minimumReleaseAgeExclude. Both are reverted, so the file differs from upstream by exactly one line: the `cmdk: 1.1.1` catalog pin this package needs. packages/cmdk is unchanged apart from one comparator re-wrapped by the refreshed prettier; the whitespace-only diff is the entire delta. Verified: 43/43 cmdk and cmdk-ssr against the new compiler, 48/48 evals (including the corpus freshness gate), tsrx-tsc, tsgo, prettier, and all five generated-artifact gates current.
This branch was previously deployed
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.

What
P1 of the news-benchmark hydrate regression plan: production hydration no longer parses (or clones) compiler templates on the happy adoption path.
hydrationNodeMatchesearly-returns after the tag check in prod; dev keeps the full deep walk, attribute compare, andwarnHydrationStructuralMismatchunchanged. All divergence isprocess.env.NODE_ENV-guarded (build-time stripped).LazyTemplateRecordgains a lazily-computedrootdescriptor (charcode scan — element tag, or nodeType 3/8 for text/anchor roots; the compiler-prewrappedoctane-fragtag marks HTML multi-root fragments). The exportedclone()routes prod-hydrating lazy templates to a newcloneLazycapability entry; it and the dev/non-lazycloneshare one privateadopt(), which resolves the parse only on cold paths: mismatch recovery, cursor-null client builds, and the once-per-hydrateRootfragment root claim.toLowerCase(SVG case-adjustment table), and the HTML parser's one tag rewrite (<image>→img) is special-cased so it can't cause silent prod rebuilds.Node.prototype.cloneNodespy).Documented narrowing
In prod, same-tag branches differing only in static attributes (e.g.
@switchcases all<span>with differentclass) are no longer detected, so no recovery fires for them; dev still warns + rebuilds. Tag-level and text-level mismatches still detect and recover in prod (text holes self-correct via the compiler-seeded prev value). Documented indocs/differences-from-react.mdanddocs/react-parity-migration-plan.md.Tests
New prod-runtime describe in
mismatch-structural.test.ts(stubsNODE_ENV=production; the runtime reads it at call time): parse-free + clone-free happy adoption, tag-level detection + silent recovery, the attribute-narrowing divergence (// OCTANE DIVERGENCE), and multi-root fragment adoption. The two contract-changing tests fail against the pre-change runtime; the recovery tests pass in both worlds. No existing tests weakened.Validation
pnpm test: 12,086 / 12,087 across all projects incl.octane-prodand the website SSR-hydration e2e. The one failure is environmental and pre-existing: stale untracked pnpm leftovers inpackages/tanstack-start/vendor/trippackage-boundary.test.tslocally (rm -rffixes it; nothing tracked).pnpm typecheck,pnpm format:check: clean.Benchmark (news, prod builds, headless Chromium, 20 iters, same machine/run)
Harness correctness gates green both runs (
no-rebuild=true,interactive=true). Gap vs Svelte: 1.19× → 1.03×, before P0 (static template-namespace resolution, separate session) stacks on top.🤖 Generated with Claude Code
Note
Medium Risk
Changes core hydration adoption and narrows prod structural mismatch detection (same-tag/static-attribute divergences may persist until client updates), though tag/text recovery and extensive new prod tests mitigate regressions on the hot path.
Overview
Production hydration no longer parses or clones compiler templates when server markup matches the client’s expected root nodeType + tag. The adoption check reads a lazily cached root descriptor from the template HTML string (
cloneLazy/lazyRootMatches), so the happy path only compares against the server cursor.Structural validation is split by environment: in production,
hydrationNodeMatchesstops afterlocalName(React parity—no static-attribute or nested-static walk). Tag and text mismatches still recover; same-tag branches that differ only in static attributes are not detected in prod (dev keeps full compare, warnings, and rebuild). Template parsing is deferred to mismatch recovery, cursor-null client builds, and fragment root claims.Docs and a new prod-runtime test block pin the contract (parse/clone-free adoption, silent tag-level recovery, attribute-narrowing divergence, fragment adoption).
Reviewed by Cursor Bugbot for commit ffcc24b. Bugbot is set up for automated code reviews on this repo. Configure here.