Skip to content

fix(octane): enumerate deferred JSX values with ordinary element keys - #1659

Merged
trueadm merged 2 commits into
mainfrom
claude/compassionate-wozniak-c136e3
Oct 3, 2026
Merged

trueadm merged 2 commits into
mainfrom
claude/compassionate-wozniak-c136e3

Conversation

@trueadm

@trueadm trueadm commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

benchmarks/scoped-descriptor-shapes pins a scoped descriptor's own enumerable keys to ['$$kind', 'type', 'props', 'key', 'ref', 'children'], the same keys an ordinary createElement descriptor has. Since #1069, the client's scopedValueDescriptor has defined an enumerable seventh accessor, __octaneInvocationSite. An ordinary descriptor gets that field only when a call site exists. As a result, the client half of the suite failed with + '__octaneInvocationSite', and the weekly run reports it as a hard error.

Contract: a deferred JSX value (createScopedValue / nativeCreateScopedValue) enumerates exactly the public element keys. __octaneInvocationSite stays an own getter, so every internal read keeps working, but it is non-enumerable. The server twin already made this choice (enumerable: false), and ssr-element-utils.test.ts already pins the six keys there. This PR brings the client into line.

Why not the alternatives:

  • Define the key only when a site exists: a scoped value can't know whether its record has a site without running the deferred resolver. The suite asserts that creation never runs it.
  • Put the key on every descriptor: that adds a slot to every createElement call and exposes an internal field through every element's Object.keys.

The pinned keys in run.mjs are unchanged.

Changes

  • runtime.ts: the scoped-value __octaneInvocationSite accessor is now enumerable: false.
  • runtime.ts and runtime.server.ts both get the same comment explaining the constraint, so the twins stay aligned.
  • scoped-jsx-values.test.ts: Object.keys and for...in on a client scoped value match createElement, and enumerating doesn't run the resolver.
  • hydration/signal-instance-identity.test.ts: two dynamic JSX values from distinct call sites render the same component. Each holds a signal$ and a streamed query, run through prerender and hydrateRoot, in dev and prod compile. This guards the neighbouring behaviour: the call site must still reach signal identity through the now-hidden getter.
  • Patch changeset for octane.

Validation

  • pnpm format:check: not run repo-wide. pnpm format:files on all changed files reported them unchanged, and the changeset passes the check.
  • pnpm typecheck: not run repo-wide. pnpm typecheck:files is clean for both runtimes and the hydration test. scoped-jsx-values.test.ts reports TS6142 on its .tsx fixture import under the scoped tool, and the file at main reports the same error, so it predates this change.
  • pnpm test: not run locally; left to CI.
  • targeted tests, octane project:
    • scoped-jsx-values.test.ts: 365 passed. The new enumeration test failed before the fix with the extra key.
    • New signal-instance-identity case: passes. I broke the scoped-value getter deliberately and confirmed it goes red each time:
      • client-only: the browser refetches both queries during hydration;
      • server-only, or both: the server renders left, left.
    • A signal$-only fixture missed the client-only break, because the signals-module child binding masks it. That's why the case also includes a streamed query.
  • node benchmarks/scoped-descriptor-shapes/run.mjs 3 passes for client and server (48 targets), both before and after rebasing onto current main.
  • Paired timing against a frozen main build, run alternately (baseline, fix, fix, baseline; 9 samples each, Node, macOS arm64). The baseline fails the key assertion, so both builds ran through one scratch copy of the harness with only that assertion relaxed. The machine's load average was about 30, so treat these as noisy. Adjusted for the plain-element control, scoped-value results at 1,024 items were 0.91–1.05× of baseline, which shows no regression. 47 of 48 output hashes matched across all four runs. The one that changed, client-scoped-value-enumerate-1024, is the intended fix: the baseline's for...in also returned the internal key.

Risk / follow-ups

  • Copying a scoped value by spread now drops the site on the client. The server already behaved that way, so client and server now agree. Nothing in the runtime or any binding spreads or Object.assigns a descriptor.
  • Ordinary compiled component descriptors still list __octaneInvocationSite in Object.keys, as before. Hiding it there would touch the createElementFromConfig hot path, so it's left as a separate decision.
  • The PR bench report flags small compressed-size increases (+1 to +15 B gzip/brotli on octane-jsx and the base-ui/radix reachability bundles), while brotli fell 50–70 B on the two Vite reachability bundles. Raw bytes are unchanged: the only emitted change is one enumerable:!0 becoming !1, which breaks a run of identical descriptor literals. Minifying the client runtime locally gives the same picture: +2 B gzip and +107 B brotli for false. Omitting the field, which also defaults to non-enumerable, gives −14 B raw but +1 B gzip / +56 B brotli. I kept the explicit false, matching the server.
  • There's no HARNESS_FAILURE_ALLOWLIST entry to remove. ci(bench): triage the weekly ratio-guard breaches so new ones show #1641 dropped its temporary waiver for this suite in 0e37411, so the suite stays a hard error in the weekly run until this lands.

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

Low Risk
Small descriptor-metadata change with targeted tests; main behavioral note is that object spread on the client now omits the invocation site, matching existing server behavior.

Overview
Aligns deferred JSX values (createScopedValue) on the client with ordinary createElement descriptors for enumeration: Object.keys, for...in, and spread no longer surface the internal __octaneInvocationSite getter.

The client scoped-value descriptor sets that property to enumerable: false (the server already did), with a shared comment in runtime.ts and runtime.server.ts. Runtime reads of the call site are unchanged; only public key lists match the benchmark contract ['$$kind', 'type', 'props', 'key', 'ref', 'children'].

Adds a unit test that enumeration matches createElement without running the deferred resolver, plus a hydration test that two dynamic JSX values at distinct call sites still keep signal and streamed-query identity separate through prerender and hydrateRoot.

Reviewed by Cursor Bugbot for commit 1c558db. Bugbot is set up for automated code reviews on this repo. Configure here.

Since #1069 the client's scoped value descriptor defined an enumerable
__octaneInvocationSite accessor, so Object.keys, for...in and spread listed
an internal seventh key that ordinary createElement descriptors carry only
when a site exists. A deferred value cannot know whether its record has a
site without resolving it, so make the accessor non-enumerable, as the
server twin already was. The getter still forwards the resolved record's
site to component slots, signal identity and SSR.

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 3, 2026
@github-actions
github-actions Bot marked this pull request as draft October 3, 2026 10:00
@trueadm
trueadm marked this pull request as ready for review October 3, 2026 10:25
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark report

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

Compares a0df40945 with 90f12a9c0 on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample also moving beyond that margin. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

All 20 timed operations (20 within noise)
target operation base head Δ noise
octane-tsrx run 3.37 3.40 +0.9% ±7% ⚪ within noise
octane-tsrx replace 6.55 6.63 +1.2% ±8% ⚪ within noise
octane-tsrx add 3.44 3.42 −0.6% ±8% ⚪ within noise
octane-tsrx update 0.30 0.30 −0.0% ±51% ⚪ within noise
octane-tsrx select 0.09 0.10 +11.1% ±112% ⚪ within noise
octane-tsrx swap 0.27 0.25 −7.4% ±62% ⚪ within noise
octane-tsrx remove 0.27 0.28 +3.7% ±57% ⚪ within noise
octane-tsrx runlots 30.09 29.58 −1.7% ±12% ⚪ within noise
octane-tsrx select_lots 0.14 0.17 +21.4% ±65% ⚪ within noise
octane-tsrx clear 31.91 30.60 −4.1% ±17% ⚪ within noise
octane-jsx run 3.64 3.64 +0.0% ±6% ⚪ within noise
octane-jsx replace 6.42 6.48 +0.9% ±5% ⚪ within noise
octane-jsx add 3.22 3.28 +1.9% ±6% ⚪ within noise
octane-jsx update 0.46 0.44 −4.3% ±35% ⚪ within noise
octane-jsx select 0.30 0.28 −6.7% ±41% ⚪ within noise
octane-jsx swap 0.55 0.53 −3.6% ±24% ⚪ within noise
octane-jsx remove 0.50 0.46 −8.0% ±23% ⚪ within noise
octane-jsx runlots 28.77 29.12 +1.2% ±5% ⚪ within noise
octane-jsx select_lots 2.32 2.17 −6.5% ±25% ⚪ within noise
octane-jsx clear 34.23 31.59 −7.7% ±12% ⚪ within noise

Application bundle size (bytes)

target metric base head Δ
octane-jsx js_gzip 72,341 72,342 +1 (+0.0%) 🔴
octane-jsx js_brotli 62,641 62,656 +15 (+0.0%) 🔴
octane-jsx app_gzip 2,936 2,935 −1 (−0.0%) 🟢
octane-jsx app_brotli 2,497 2,498 +1 (+0.0%) 🔴
octane-jsx fw_gzip 69,405 69,407 +2 (+0.0%) 🔴
octane-jsx fw_brotli 60,144 60,158 +14 (+0.0%) 🔴

39 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
binding-base-ui-vite gzip 68,108 68,110 +2 (+0.0%) 🔴
binding-base-ui-vite brotli 59,019 58,969 −50 (−0.1%) 🟢
binding-base-ui-esbuild gzip 68,068 68,070 +2 (+0.0%) 🔴
binding-base-ui-esbuild brotli 59,025 59,028 +3 (+0.0%) 🔴
binding-radix-vite gzip 68,660 68,661 +1 (+0.0%) 🔴
binding-radix-vite brotli 59,632 59,562 −70 (−0.1%) 🟢
binding-radix-esbuild gzip 68,650 68,652 +2 (+0.0%) 🔴
binding-radix-esbuild brotli 59,604 59,612 +8 (+0.0%) 🔴

97 other measured values are unchanged.

@trueadm
trueadm merged commit 0a14c20 into main Oct 3, 2026
50 checks passed
@trueadm
trueadm deleted the claude/compassionate-wozniak-c136e3 branch October 3, 2026 10:55
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