Skip to content

fix(octane): keep an early binding's whole-style publication through hydration - #1859

Merged
trueadm merged 8 commits into
mainfrom
fix/whole-style-binding-claim
Oct 7, 2026
Merged

trueadm merged 8 commits into
mainfrom
fix/whole-style-binding-claim

Conversation

@trueadm

@trueadm trueadm commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on #1854 (merged): it extends that PR's adopted style publication test. main is merged in.

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 with style: 'opacity: 1;', adopt the paragraph early, publish 'opacity: 0.5;', then hydrateRoot with 'opacity: 1;':

  • (a) False dev mismatch: confirmed. keepsStyle honored only style:<prop> claims, so development reported the early publication as a hydration mismatch ("the server rendered opacity: 0.5;").
  • (b) Missed republish: confirmed. hydrateClaimedBindingCaches found no claim for the style channel, so the renderer cached the skipped 'opacity: 1;' write as applied. After the binding was released, root.render back to exactly 'opacity: 1;' wrote nothing, and opacity: 0.5 stayed on screen. Both the ordinary setStyle cache 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): a styleObject channel now takes part in the legacy claim publication and publishes the canonical style.cssText it 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. hydrateClaimedBindingCaches already invalidates a claimed style channel'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: the if (style === 'literal') dev-warning condition is gone; every mode now asserts no report. New cases cover:
    • applying the hydration-time style after release, with both a 0.5 and an emptied publication, with no mutation on the next identical render;
    • an emptied whole style that hydrates without a report;
    • a style mutated after publication, which still warns once in dev and is then updated normally.
  • docs/deferred-hydration.md: the claim-retention paragraph now covers style channels.
  • Changeset: octane patch.

Validation

  • Failing before the fix. On perf(octane): write unset and string native styles without a Block #1854's head (identical to its squash on 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.
  • Deliberate breakage. Dropping the keepsStyle claim check fails the two dev "keeps" cases. Ignoring whether the claim matches the DOM fails the two dev "no longer matches" cases. Publishing null instead 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:files on the four changed TS files, prettier --check on the changed files, pnpm sync (no generated changes).
  • node benchmarks/bundle-size/run-minimal.mjs on the merged tree against main: 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 of main (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: keepsStyle returns 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

  • Every whole-style write by an early binding now reads style.cssText once to publish. Single-declaration writes already read the CSSOM per write.
  • A related report is still open, out of scope here: when a single-declaration early binding removes the only declaration ({ opacity: undefined }), the style="" it leaves still trips keepsStyle's attribute-presence check in development. The straightforward flag costs +16 raw / +9 gzip on hydrate-root, which exceeds that budget's headroom together with this fix, so it needs its own change.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with 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.

__adoptBindings now includes styleObject in legacy claim publication and records canonical style.cssText (including '' when cleared). HydrationCapability.keepsStyle treats 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 after dispose() 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.ts adds 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.

trueadm and others added 2 commits October 7, 2026 20:18
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]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Oct 7, 2026
@trueadm
trueadm marked this pull request as ready for review October 7, 2026 20:15
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 6 value(s) increased within budget
  • 🔴 bundle-reachability: 6 value(s) increased within budget

Compares 31724a3f9, the merge commit's first parent with bc44c6080 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.358 3.317 +0.0% −1.0% … +4.2% ⚪ within noise
octane-tsrx replace 9.558 8.875 −3.0% −9.5% … +4.1% ⚪ within noise
octane-tsrx add 3.000 3.283 −0.0% −9.1% … +6.0% ⚪ within noise
octane-tsrx update 0.150 0.148 +3.5% −3.3% … +6.8% ⚪ within noise
octane-tsrx select 0.007 0.007 +3.9% −1.8% … +11.4% ⚪ within noise
octane-tsrx swap 0.041 0.037 −5.3% −15.1% … −1.2% ⚪ within noise
octane-tsrx remove 0.023 0.022 −3.0% −8.1% … +2.5% ⚪ within noise
octane-tsrx runlots 33.192 32.600 −0.4% −11.9% … +4.5% ⚪ within noise
octane-tsrx select_lots 0.008 0.007 −2.8% −5.6% … +1.3% ⚪ within noise
octane-tsrx clear 51.392 52.242 −0.4% −2.1% … +1.1% ⚪ within noise
octane-jsx run 3.900 3.742 −2.9% −5.7% … +2.3% ⚪ within noise
octane-jsx replace 7.183 7.242 +1.5% −7.7% … +5.6% ⚪ within noise
octane-jsx add 3.308 3.217 −0.0% −3.1% … ±0.0% ⚪ within noise
octane-jsx update 0.287 0.286 −1.9% −3.2% … +1.7% ⚪ within noise
octane-jsx select 0.144 0.144 +0.3% −3.0% … +2.7% ⚪ within noise
octane-jsx swap 0.233 0.235 +1.0% −0.5% … +2.1% ⚪ within noise
octane-jsx remove 0.196 0.181 −3.5% −5.9% … −1.2% ⚪ within noise
octane-jsx runlots 40.600 37.358 −1.3% −8.9% … +5.6% ⚪ within noise
octane-jsx select_lots 1.919 1.900 +3.8% ±0.0% … +8.4% ⚪ within noise
octane-jsx clear 55.558 49.842 −1.0% −8.3% … +8.2% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx full_fw_raw 564,890 564,911 +21 (+0.0%) 🔴
octane-tsrx full_fw_gzip 169,881 169,887 +6 (+0.0%) 🔴
octane-tsrx full_fw_brotli 142,886 142,967 +81 (+0.1%) 🔴
octane-jsx full_fw_raw 564,890 564,911 +21 (+0.0%) 🔴
octane-jsx full_fw_gzip 169,881 169,887 +6 (+0.0%) 🔴
octane-jsx full_fw_brotli 142,886 142,967 +81 (+0.1%) 🔴

54 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
hydrate-root raw 137,827 137,848 +21 (+0.0%) 🔴
hydrate-root gzip 44,097 44,104 +7 (+0.0%) 🔴
hydrate-root brotli 38,588 38,582 −6 (−0.0%) 🟢
deferred-hydration raw 221,123 221,144 +21 (+0.0%) 🔴
deferred-hydration gzip 69,603 69,610 +7 (+0.0%) 🔴
deferred-hydration brotli 60,043 60,040 −3 (−0.0%) 🟢
hydrate-frame raw 366,308 366,329 +21 (+0.0%) 🔴
hydrate-frame gzip 113,376 113,382 +6 (+0.0%) 🔴
hydrate-frame brotli 96,888 96,884 −4 (−0.0%) 🟢

102 other measured values are unchanged.

trueadm and others added 2 commits October 7, 2026 21:27
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]>
@trueadm
trueadm merged commit 43b60d9 into main Oct 7, 2026
29 checks passed
@trueadm
trueadm deleted the fix/whole-style-binding-claim branch October 7, 2026 21:51
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant