Repository navigation
perf(hydration): ship island-only activation code only with <Hydrate> - #2038
Merged
Merged
Conversation
renderSuspended, finishRoot and keepChanges were HydrationCapability methods whose only caller is activateHydrateBoundary. A bundler keeps every method of a class it keeps, so every hydrating bundle carried them. As module functions beside activateHydrateBoundary they ship only with <Hydrate> islands. Their callers construct the capability themselves, so createRoot-only bundles are unchanged under Vite and esbuild. Adds island fallback cases that pin both moved branches: a resumed call whose own range has trailing server content (renderSuspended's claim) and an island whose server HTML continues past its range (finishRoot). No existing test failed when either branch was broken. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # packages/octane/src/runtime.ts
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
View logs |
octane-website | 435c2a0 | Oct 13 2026, 11:12 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
View logs |
octane-website-mcp | 435c2a0 | Oct 13 2026, 11:12 AM |
trueadm
marked this pull request as ready for review
October 13, 2026 11:13
trueadm
marked this pull request as draft
October 13, 2026 11:14
Contributor
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
76 other measured values are unchanged. Public-import reachability bundles (bytes)
102 other measured values are unchanged. |
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
renderSuspended,finishRootandkeepChangeswereHydrationCapabilitymethods whose only caller isactivateHydrateBoundary, the<Hydrate>island activation. A bundler keeps every method of a class it keeps, so every hydrating bundle carried them, islands or not. This PR moves them to module functions besideactivateHydrateBoundary, so they ship only with<Hydrate>. Behavior is unchanged.Gates code in the area that #2028 (#2028) redesigns. It moves island-only code next to the feature that creates the capability, so the gain survives the planned collapse into a cursor.
Why only these three
A dead-member scan of the hydrating fixtures found 13.1 KB of never-called class members on
hydrate-root, 7.2 KB ondeferred-hydrationand about 1.3 KB onhydrate-frame. Most of that comes from methods called by client-reachable code:childSlot,setStyle/setAttribute,mountTry,forBlock,ifBlock,childTextHoleand others. Moving those breaks the documented flag invariant (hydration-flag.ts,run-hydration-free.mjs): esbuild never foldshydrating, so hydration bodies must stay on the capability or an installed driver.A probe moved
keepsStyleout of the class.create-root-export-vitestill dropped it, butcreate-root-export-esbuildretained it. The broad move would therefore add each feature's hydration bodies to esbuild createRoot-only bundles (Rspack untested), and only Vite hydrating fixtures would shrink. The 13 KB onhydrate-rootcomes mostly from it being a one-component fixture. These three are the only dead members whose caller constructs the capability itself, so client-only bundles cannot reach them under any bundler.Changes
packages/octane/src/runtime.ts: the three methods becomerenderSuspended(hydration, source),finishRoot(hydration)andkeepChanges(hydration)aboveactivateHydrateBoundary, with their doc comments unchanged. The six fields they read lose TSprivate; runtime shape is unchanged.packages/octane/tests/hydration/unframed-component-range.test.tswith a newHeldBranchfixture: an island whose server HTML has an element the client renders nothing for, found once a suspended call resumes. One case puts it inside the call's own range, where onlyrenderSuspended's restored claim catches it. The other puts it after the island's range, where onlyfinishRootcatches it. Both cases run under development and production compiles.octanepatch.Validation
Bundle size,
node benchmarks/bundle-size/run-minimal.mjs(Vite 8 + oxc), base 5594cb0 against head:deferred-hydrationuses an island, so it keeps all three functions. Its small change comes from the code no longer being class methods.Other checks:
node benchmarks/bundle-size/run-hydration-free.mjs: all 15 client bundles hydration-free, controls pass.vitest run --project octane tests/hydration/unframed-component-range, 50 passed.renderSuspended's claim branch disabled, only the in-range case fails, under both compiles. WithfinishRootas a no-op, only the after-range case fails, under both compiles.finishRootmismatch branch reached by none. With the claim disabled, all 252 tests in those 8 files still passed.pnpm typecheck:fileson the three changed source and test files: pass.pnpm format:files:checkon the changed files: pass.pnpm sync: clean.pnpm format:check,pnpm typecheck,pnpm test: left to CI.perf-review:node scripts/perf-review-scan.mjsfound no candidates. No hot path is touched: the three functions run once per<Hydrate>activation attempt, and their only call sites are the existing ones inactivateHydrateBoundary. No compiled output changes, and no new imports or references reach client paths (byte-identical createRoot rows).benchmarks/app-frame-hydrationhas no islands, so it never runs this code; no paired run.concise-code:HeldBranchis a test-fixture export.activateHydrateBoundarygives the same bytes, since oxc already inlines single-use functions, and loses the names other comments cite.Risk / follow-ups
keepChangesonly drops the finished island attempt's undo records, and the capability is released right after. A break there cannot be observed from tests, so no test pins it.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Low Risk
Refactor-only relocation of existing island activation paths with new tests and verified bundle shrink; no intended hydration behavior change.
Overview
Moves island-only hydration logic out of
HydrationCapabilityinto module-level helpers (renderSuspended,finishRoot,keepChanges) colocated withactivateHydrateBoundary, so bundles that callhydrateRootwithout<Hydrate>can drop that code (~0.4 kB minified). Call sites in island activation now invoke the free functions; several capability fields loseprivateso those helpers can read them—runtime behavior is unchanged.Adds
HeldBranchfixtures and parameterized tests covering mismatch detection after a suspended call resumes (extra server element inside the call’s range vs after the island’s range), guarding the refactoredrenderSuspendedandfinishRootpaths. Includes anoctanepatch changeset.Reviewed by Cursor Bugbot for commit 435c2a0. Bugbot is set up for automated code reviews on this repo. Configure here.