Skip to content

fix: preserve render ownership for JSX values - #355

Merged
trueadm merged 4 commits into
octanejs:mainfrom
openai-oss-forks:fix/353-scoped-jsx-values
Jul 28, 2026
Merged

trueadm merged 4 commits into
octanejs:mainfrom
openai-oss-forks:fix/353-scoped-jsx-values

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve the represented provider, ErrorBoundary, and Suspense when a context-sensitive JSX child is moved into a variable, prop, array, or another value position.
  • Defer effectful JSX child expressions through one stable compiler-owned component while preserving ordinary element descriptors, child inspection, cloning, and the existing direct-render fast paths.
  • Keep client rendering, server rendering, and hydration on the same copy-on-write compiler/runtime ABI.
  • Add consumer-observable TSRX and TSX regressions for direct and value-position context reads, built-in and wrapped synchronous error boundaries, built-in and wrapped Suspense ownership and resolution, hydration identity, nested TSRX directives, and ordinary JSX values.
  • Add an octane patch changeset.

Root cause

Value-position JSX was lowered into eager createElement(..., children) arguments. Calls in a represented host child therefore ran while constructing the enclosing descriptor, before its provider or wrapper boundary had entered its scope. Direct templates and statically lowered built-in ErrorBoundary did not have this problem because their child expressions ran inside a scoped render body. Scope-sensitive value expressions now retain their surrounding element shape and execute through one compiler-only component after their actual render scope is established.

Validation

Passed locally:

  • node --check packages/octane/src/compiler/compile.js.
  • node --experimental-strip-types --check for the client runtime, server runtime, both runtime entry points, and the new regression suite.
  • Targeted Prettier 3.9.6 formatting for every locally parseable changed JS, TS, and TSX file using the repository's checked-in formatting settings.
  • node scripts/check-changesets.js.
  • node scripts/check-test-markers.mjs.
  • node scripts/check-tsrx-module-decls.mjs.
  • git diff --cached --check.
  • Normal Git commit signing, with verified signature status G.

The exact frozen install cannot complete locally because the configured protected registry rejects the locked @tsrx/[email protected] tarball with HTTP 403. The locked parser and registry credentials have not been changed or bypassed. The complete pnpm format:check, pnpm typecheck, development/production Vitest suites, frozen-AST/source-origin checks, and browser/integration checks therefore need the upstream GitHub Actions environment.

Performance and compatibility

Ordinary literal and identifier JSX children keep their current descriptor fast path and allocate no additional component or thunk. Only expressions capable of reading context, throwing, or suspending enter the scoped path. The protected-parser restriction prevents a trustworthy local benchmark, so this change does not claim a measured performance improvement.

Closes #353


Note

Medium Risk
Touches JSX lowering and the compiler/runtime ABI on paths that affect context, errors, and Suspense; behavior change is intentional but limited to expressions that can read context, throw, or suspend.

Overview
Fixes incorrect render timing when JSX subtrees live in variables, props, arrays, or other nested value positions: effectful child expressions (context via use, throws, await/Suspense) were running while building createElement arguments, before the represented Provider, ErrorBoundary, or Suspense was active.

The compiler now detects scope-sensitive JSX child expressions (jsxChildNeedsRenderScope) and lowers them to a renderScopedValue descriptor that evaluates a deferred read thunk only after the owning boundary is entered. Plain literals/identifiers and function-valued children keep the existing fast path.

Client and server runtimes gain matching renderScopedValue helpers (exported on the compiler ABI), and new TSRX/TSX tests cover context, error boundaries, Suspense, hydration, and ordinary element inspection/cloning.

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

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

@domgan-oai is attempting to deploy a commit to the Ripple Team Team on Vercel.

A member of the Team first needs to authorize it.

@trueadm
trueadm merged commit d40da54 into octanejs:main Jul 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSX expressions run in different contexts depending on how the JSX is used

2 participants