Repository navigation
fix(hydration): keep a hookless component's signal level below its arms and rows - #1616
Merged
Merged
Conversation
…ms and rows A hookless (lite) component's arms, rows and value children hang off its LiteBlockImpl DOM stand-in. The stand-in was never stamped and has no forSlot field, so the signal instance key walk skipped the component's level and pushed a stray 'u:' item token. The browser keyed those owners differently from the server, and the retry-path walk let later hookless siblings collide on one path, so they swapped owners on a hydration retry. Stamp the stand-in with its lite scope's recipe and read forSlot loosely in the signal walks, so a stand-in never counts as a list row. The root-chained-jsx bundle is 21 B smaller raw and 1 B larger gzip; main sat exactly on its gzip budget, so that budget moves up one 32 B step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 2, 2026 22:23
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)All 20 timed operations (20 within noise)
Application bundle size (bytes)
10 other measured values are unchanged. Public-import reachability bundles (bytes)
40 other measured values are unchanged. |
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
A component rendered inside an
@ifor@forarm of a hookless (lite).tsrxcomponent got a different signal instance key in the browser than on the server. Hydration therefore started fresh cells instead of resuming the server's. This was found while working on #1601; it predates that PR and is independent of it.For a value under a lite component's
@ifarm, before this change:["","root"]["c:<Card>",[],""]["c:<Leaf>",[],""]["","root"]["c:<Leaf>",["u:"],""]The client dropped the lite component's level and added a bogus
u:item token.Cause. Arms, rows and value slots created in a lite body hang off the lite scope's
LiteBlockImplDOM stand-in, not the scope. The stand-in was never stamped, so the key walk skipped the component's level. It also has noforSlotfield, soforSlot !== nulltreated it as a list row and pushedu:. Nested lite components lost every lite level the same way.Second bug, same cause.
signalRetrySlotused the same strict check. On a lite target,undefined === undefinedmatched slots belonging to an earlier lite sibling, so later lite siblings collided on one retry path. When hydration retried a suspended@trybody, the second sibling took the third's owner. This only happens in dev builds, where the earlier sibling is also compiled lite.Fix. The fix is on the stamping side, in
packages/octane/src/runtime.ts:stampSignalInstancenow stamps the stand-in with its lite scope's recipe, so the walks resolve the component's level there. It now writes only the parent and site, because the scope is always freshly created at that point.structuralSignalInstanceKey,signalRetrySlotandscopeSignalOwnerreadforSlotloosely, so a stand-in never counts as a list row.LiteBlockImplaforSlot = nullfield. That cost +18 B raw and +42 B brotli in every bundle. It would also have changed childSlot's passthrough list-anchor walk, which stops at a stand-in's end marker.invalidateRenderalready skips stand-ins.Bundle size.
root-chained-jsxagainst main 6ea582e:mainalready sat exactly on the gzip budget (28544). Every equivalent spelling of the reader checks was +1 to +8 B gzip or over the brotli budget; I measured 24 of them. This PR therefore raises only theroot-chained-jsxgzip budget by one 32 B step, to 28576, as #1548, #1549 and #1582 did. All five gated scenarios are 21 B smaller raw. The other four stay within budget, between −2 and 0 B gzip and between −6 and +63 B brotli.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkpassed on the 4 changed files.pnpm typecheck: not run repo-wide.pnpm typecheck:filespassed on the runtime and the test file.pnpm test: not run locally. CI covers it.vitest run --project octane packages/octane/tests/hydration/signal-instance-identity.test.ts, 167/167 passing.hookless component signal instance identity, 14 cases in dev and prod.@if(component and host roots), a value under@for, a component under@if, and nested hookless arms. Each case asserts every browser owner key equals the server's key for the same component, plus DOM adoption.use()suspension and hydration retry, after an earlier hookless sibling that contains a nested hookless child or an@ifarm.signalRetrySlotcheck, the dev retry cases fail.node benchmarks/bundle-size/run-minimal.mjs --budgets root-static-local root-chained-jsx hooks-state prop-attributes contextpasses.Risk / follow-ups
scopeSignalOwnerreader change only matters for a lite scope mounted before signals were enabled. In that case it now behaves like an unstamped full component Block, and no test covers it.root-chained-jsxremains close to its budget on all three metrics, so the next runtime change on this path will likely need another step.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 core hydration signal-identity and retry-slot resolution in the client runtime; behavior is narrow but mistakes would corrupt resumed signal state across SSR/hydration.
Overview
Fixes server/client signal instance key mismatches for content rendered inside
@if/@forarms of hookless (lite).tsrxcomponents, so hydration resumes the server’s signal cells instead of creating new ones.Runtime (
runtime.ts):stampSignalInstancenow copies the lite scope’s parent/site onto theLiteBlockImplDOM stand-in as well as the scope, because structural children key off the stand-in.forSlotis checked loosely insignalRetrySlot, structural key walks, andscopeSignalOwnerso unstamped stand-ins are not treated as list rows (no bogusu:token) and lite siblings don’t collide on hydration retry paths after a suspended@try.Tests: New
hookless component signal instance identitycoverage (dev + prod) for several arm/row shapes and for sibling owners after browser-only suspension + retry.Release / CI: Octane patch changeset;
root-chained-jsxminimal bundle gzip budget +32 B (28544 → 28576).Reviewed by Cursor Bugbot for commit 44f5683. Bugbot is set up for automated code reviews on this repo. Configure here.