Repository navigation
fix(octane): keep an early binding's whole-style publication through hydration - #1859
Merged
Merged
Conversation
A module that imports octane/signals compiles every non-literal style, such as
a forwarded style={props.style}, to nativeStyleBinding, because the value might
carry signal handles. The binding then allocated and rendered a control-flow
Block even for undefined, null or a string, which carry no native read. A
production audit of a signed-out home page found 273 such Blocks in one
hydration (about 8 ms at 4x CPU throttling).
Any non-object value now takes the existing scalar writer while the binding has
no Block, whatever the compiler's literal flag. Presentation hydration prepares
the same plain style takeover write without a Block or read witness. The
existing upgrade still allocates the Block, seeded with the last applied style,
once a structured value arrives; the Block then stays, so a later unset style
releases its subscriptions through its own transactional render.
hydrateClaimedBindingCaches dereferenced binding.block for every native style
claim. A Block-less scalar style literal in a signal-enabled binding view made
hydration throw, so the host was rebuilt on the client; it now updates the
binding's own cache.
nativeProjectionBinding is unchanged: the compiler emits it only for
projections that syntactically read handles, so its Block owns real reads.
The signal-dom-bindings bench gains a forwarded-style lane with ratio guards:
style Blocks 2 -> 0 and native style bodies 200 -> 0 per 100 updates.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hydration
An early binding that owned a whole style (`style={props.style}`, a
`styleObject` channel) never recorded a claim for hydration. Development
therefore reported its publication as a mismatch, and hydration cached the
skipped write as applied: after the binding was released, a render back to the
hydration-time style did not write it, so the early value stayed on screen.
The fixed-layout adopter now publishes a whole style's canonical CSS text, and
keepsStyle treats a matching whole-style claim as the server's value, as it
already did for single declarations. hydrateClaimedBindingCaches already
invalidates the renderer's cache for a claimed `style` channel.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ng-claim # Conflicts: # packages/octane/tests/binding-handoff.test.ts
trueadm
marked this pull request as ready for review
October 7, 2026 20:15
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)
54 other measured values are unchanged. Public-import reachability bundles (bytes)
102 other measured values are unchanged. |
The repository's test-marker check forbids `it.runIf`. The emptied-publication case applies only to a whole style, so it now has its own describe over dev/prod and signals-free/signals-enabled views. The view, props and early adoption helpers it shares with the main matrix are hoisted into `adoptedStyleView`, so every registered test runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3 of 6 tasks
4 of 7 tasks
domgan-oai
pushed a commit
that referenced
this pull request
Oct 7, 2026
…1869) Budget-only raise, landing ahead of #1861 per CONTRIBUTING "Size budgets". main 43b60d9 measures deferred-hydration at exactly its 69,610 gzip budget (#1857 and #1859 filled the headroom). #1861 stops development hydration reporting an empty style attribute that an early binding left behind, and measures 69,612 gzip there (-14 raw, +2 gzip). 69,642 is main's measured + 32, the highest value the ratchet accepts against main, so no other pull request fails the ratchet while #1861 is open. 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
An early binding (
adoptBindings) that owns a whole style, such as<p style={props.style}>in a'use dom bindings'view, never published its value for hydration. Single-declaration bindings (style={{ opacity: props.opacity }}) already did. Reproduced in both a signals-free and a signals-enabled (import 'octane/signals') view: SSR withstyle: 'opacity: 1;', adopt the paragraph early, publish'opacity: 0.5;', thenhydrateRootwith'opacity: 1;':keepsStylehonored onlystyle:<prop>claims, so development reported the early publication as a hydration mismatch ("the server renderedopacity: 0.5;").hydrateClaimedBindingCachesfound no claim for thestylechannel, so the renderer cached the skipped'opacity: 1;'write as applied. After the binding was released,root.renderback to exactly'opacity: 1;'wrote nothing, andopacity: 0.5stayed on screen. Both the ordinarysetStylecache and the Block-less native style binding hit this.React has no early-binding concept, so the reference is its hydration contract for an adopted element: hydration keeps the server's attribute value without patching, and development warns only about a genuine server/client difference. An early binding's claimed publication is Octane's documented exception: it counts as the server's value. A value changed after publication still hydrates like any other server value and is reported, as in React.
Changes
dom-bindings.ts(__adoptBindings): astyleObjectchannel now takes part in the legacy claim publication and publishes the canonicalstyle.cssTextit left in the DOM (''when no declarations remain).runtime.ts(HydrationCapability.keepsStyle): a whole-style claim equal to the server's CSS text suppresses the report, as single-declaration claims already did.hydrateClaimedBindingCachesalready invalidates a claimedstylechannel's cache, so recording the claim is enough to fix (b).dom-binding-claims.ts: the comment now documents the whole-style claim value.binding-handoff.test.ts: theif (style === 'literal')dev-warning condition is gone; every mode now asserts no report. New cases cover:docs/deferred-hydration.md: the claim-retention paragraph now covers style channels.octanepatch.Validation
main), 12 of the new forwarded-style cases fail across dev/prod × signals-free/signals: the republish in all four modes, and the false report in both dev modes. The literal (per-declaration) cases stay green as the control.keepsStyleclaim check fails the two dev "keeps" cases. Ignoring whether the claim matches the DOM fails the two dev "no longer matches" cases. Publishingnullinstead of''for an emptied style fails the two dev "emptied" cases.vitest --project octane packages/octane/tests/binding-handoff.test.ts: 78 passed, 4 skipped (the whole-style-only case is skipped for literal styles).vitest --project octane packages/octane/tests/behavior-root.test.ts(lease and handoff paths): 327 passed.pnpm typecheck:fileson the four changed TS files,prettier --checkon the changed files,pnpm sync(no generated changes).node benchmarks/bundle-size/run-minimal.mjson the merged tree againstmain: only the three hydrating scenarios change, by +21 raw / +7 gzip each (hydrate-root,deferred-hydration,hydrate-frame). All three stay within their committed budgets.hydrate-frame's raw size is path-dependent, so the check uses CI's own measurement ofmain(364,850 raw in perf(octane): keep the transition and hidden-Activity graphs out of Suspense-only bundles #1855's shard 1/4), which leaves 32 bytes of headroom; my local checkout measures it 36 bytes higher. The early adopter itself grows +69 raw with no gate. Production hydration cost is unchanged:keepsStylereturns before the new code unless server values are stale, and the claim lookup runs only on a mismatch.pnpm format:check,pnpm typecheck,pnpm test: left to CI (local load rule).Risk / follow-ups
style.cssTextonce to publish. Single-declaration writes already read the CSSOM per write.{ opacity: undefined }), thestyle=""it leaves still tripskeepsStyle's attribute-presence check in development. The straightforward flag costs +16 raw / +9 gzip onhydrate-root, which exceeds that budget's headroom together with this fix, so it needs its own change.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 hydration mismatch detection and write-cache behavior for inline styles during early-binding handoff; scope is narrow but correctness-sensitive for deferred hydration.
Overview
Fixes early binding handoff for whole inline
style(e.g.style={props.style}) so it matches behavior that single-declaration styles already had.__adoptBindingsnow includesstyleObjectin legacy claim publication and records canonicalstyle.cssText(including''when cleared).HydrationCapability.keepsStyletreats a matching whole-style claim like the server value, avoiding false dev hydration warnings when the early binding changed style before hydrate. That claim also lets hydration invalidate the skipped write cache, so afterdispose()the renderer applies hydration-time props even when they match historical SSR values.Docs and a patch changeset describe whole-style claim retention.
binding-handoff.test.tsadds shared helpers and cases for post-release republish, emptied whole styles, and DOM drift after publication (forwarded and literal styles, dev/prod, signals on/off).Reviewed by Cursor Bugbot for commit 136de5c. Bugbot is set up for automated code reviews on this repo. Configure here.