Repository navigation
perf(hydration): keep the streamed-boundary validator out of client-only @try apps - #1623
Merged
Merged
Conversation
…nly @Try apps mountTry claimed a streamed shell's pending <template> sentinel inline, so every client app with @try/Suspense retained stream-protocol's isRendererStreamBoundaryTemplate -> rendererRangeClose -> hydrationMarkerMultiplicity graph even though it never hydrates. The claim is now HydrationCapability.claimStreamTemplate, which returns the boundary id or null; behavior is unchanged. suspense-transition: -1227 raw / -406 gzip / -256 brotli. Hydrating bundles: +85 raw, +5..11 gzip. run-minimal gates the validator's absence for never-hydrating clients, with hydrate-root as the control. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)
All 20 timed operations (19 within noise)
Application bundle size (bytes)No changes across 45 measured values. Public-import reachability bundles (bytes)
96 other measured values are unchanged. |
trueadm
marked this pull request as ready for review
October 3, 2026 00:43
This was referenced Oct 3, 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
mountTryclaimed a streamed shell's pending<template data-oct-b>sentinel inline. As a result, every client app that uses@try/Suspense retained stream-protocol'sisRendererStreamBoundaryTemplate→rendererRangeClose→hydrationMarkerMultiplicitygraph, even though it never hydrates.The claim is now
HydrationCapability.claimStreamTemplate(cursor, end). It returns the boundary id, or null when the cursor isn't a renderer sentinel.HydrationCapabilityis constructed only on hydration paths, so client-only bundles drop the validator along with the class. The method body is the old branch body, unchanged: it removes the sentinel and the server fallback up tostate.end, then sets the cursor.mountTrysetshasScopedBoundary,freshBoundary,streamedBoundaryIdandadoptCursorfrom the result.The other stream-protocol callers (
resolveEventPath,isDormantServerHydrateOwner,hasPendingHydrateStreamReveal,permanentStaticHydrationRangeEnd) are only reachable from hydrating code. After this change, none of the validator's exports render in any never-hydrating client scenario.capture-onlystill keeps the validator, legitimately, through event-capture.Bundle size
node benchmarks/bundle-size/run-minimal.mjs <scenarios>, one run before and after (byte counts are deterministic):The hydrating bundles grow slightly because of the method's definition and call.
dom-binding-protocol.tsstays insuspense-transitionon main, becausebindingTextstill retains it. The separate binding-text change moves that path intoHydrationCapability. Checked with an unminified Vite probe, the module leavessuspense-transitiononly when both changes are applied; either one alone keeps it.Reachability gate
run-minimal.mjsaddsstreamClaimFreeClientScenarios, the nine never-hydrating client scenarios. Each must not renderisRendererStreamBoundaryTemplatefrom stream-protocol.hydrate-rootis the control: it must still keep the export, so a rename can't make the check pass silently.The check reads export names rather than whether the module is emitted. Every client bundle still ships about 104 bytes of stream-protocol, from the module-level
`template[${STREAM_BOUNDARY_ATTR}]`selector that Rolldown can't drop. That leak is a separate follow-up.Validation
pnpm format:check: scopedpnpm format:files:checkon the changed files onlypnpm typecheck: scopedpnpm typecheck:filesonruntime.ts, the fixture and the test only. No new errors versus main; the 117 errors in that selection are pre-existing, in the untyped streaming fixtures.pnpm test: left to PR CIstreaming-ssr.test.ts: 73/73 on bothoctaneandoctane-prod.stream-ownership-collisions+ssr-stream-state-regressions: 26/26.ssr-suspensefixture users (ssr-suspense,ssr-rejection-hydration-fidelity,ssr-render-options,hydration/suspense-hydrate): 112/112.node scripts/react-parity/check.mjs --validate-only: current.run-minimal.mjson the scenarios above, with the new gate: passes.claimStreamTemplatedisabled, 8 existing streaming tests fail, including "claims a still-pending shell…" (both variants) and "hydrates a pending shell with the template boundary useId namespace".this.node = end). The new test "keeps the client fallback when a root-level pending shell is claimed" (RootBoundaryfixture) fails without it, because the root sweeps the client's fallback. It also fails with the claim disabled.The local test runs above were against the pre-rebase base (6ea582e and 62e76bf). The rebase onto #1613/#1615 applied cleanly; CI runs the current head.
Risk / follow-ups
@tryhydrated before its segment swaps has a separate bug: it reports a spurious "stale remainder was discarded" recoverable error and loses the boundary's end marker. The cursor parks onend, but a root-level slot must park past it. fix(hydration): park past every boundary, list, and activity range #1621'sparkPastaftermountTryfixes this; I applied its runtime diff locally and the error and lost marker both go away. The new test therefore doesn't assert on recoverable errors. Once fix(hydration): park past every boundary, list, and activity range #1621 lands, the test can add that assertion, and the cursor write here becomes redundant.suspense-transitionto that change'smarkerFreeClientScenarios.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Refactors hydration-critical
@try/stream boundary claiming; behavior is covered by existing and new streaming tests, but mistakes could affect streamed SSR hydration or root-level boundaries.Overview
Moves streamed
<template data-oct-b>boundary claiming off the generic@trymount path and ontoHydrationCapability.claimStreamTemplate, which only exists when hydrating. Client-only@try/Suspense apps no longer pull instream-protocol'sisRendererStreamBoundaryTemplateand related range-marker helpers (~400 B gzip onsuspense-transition);hydrateRootbehavior is unchanged—the same DOM cleanup and cursor update, now behind the hydration method.mountTrydelegates tohydration.claimStreamTemplate(adoptCursor, state.end)instead of inlining the validator. Bundle reachability addsstreamClaimFreeClientScenariosand asserts those scenarios do not export the validator, withhydrate-rootas the control that must still include it.Adds
RootBoundaryand a streaming SSR test ensuring that when the boundary is the root's only output, claiming the pending shell does not discard the client-mounted fallback before resolve.Reviewed by Cursor Bugbot for commit f501dc5. Bugbot is set up for automated code reviews on this repo. Configure here.