Skip to content

fix(octane): scope JSX values and prevent deep SSR stack overflows - #361

Merged
trueadm merged 6 commits into
octanejs:mainfrom
openai-oss-forks:fix/scoped-jsx-render-bodies
Jul 28, 2026
Merged

trueadm merged 6 commits into
octanejs:mainfrom
openai-oss-forks:fix/scoped-jsx-render-bodies

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Defer the complete compiler-authored JSX element record—dynamic root type, props, key/ref, and descendants—until its represented render scope is active, addressing the latest human review and the direct-return server-rendering mismatch.
  • Keep JSX values as ordinary inspectable element descriptors: isValidElement, Children.only, cloneElement, and direct type/props/children inspection resolve the record in the inspecting caller's current scope.
  • Preserve static JSX, explicit createElement, fragment/indexed-child compatibility, native event/render-prop semantics, hydration identity, and existing client/server descriptor topology.
  • Preserve the existing fix for cold 1,000-level buffered and streaming server component trees without changing the separate JSX/TSRX performance work.
  • Repair the failing package-build integration check by accepting current Rsbuild occupied-port diagnostics while still requiring strict-port startup to fail.

Why

Deferring only descendants left root member tags, getter-backed attributes, component props, and spreads evaluating before their represented Provider, Suspense boundary, or ErrorBoundary. The server's direct .tsx return path also exposed this mismatch as incorrect SSR markup and hydration disagreement. A lazy but normally inspectable complete descriptor resolves all of those cases uniformly without introducing additional component boundaries or hydration markers.

Changes

  • Introduce matching client/server compiler-ABI createScopedValue helpers for dynamic root records, retaining createScopedElement child deferral and leaving statically provable JSX on its existing fast path.
  • Cache deferred records by active scope and client context epoch; stamp the concrete committed descriptor on deoptimized host nodes so Provider updates correctly diff previous attributes and Suspense cleanup never evaluates user getters outside render.
  • Cover direct-return SSR, root getter attributes, spreads, component props, dynamic component tags, descriptor inspection/cloning, shared descriptors, Provider updates, independent server requests, hydration adoption, nearest ErrorBoundary ownership, and Suspense resolution/cleanup across TSX and TSRX.
  • Update the compiler-artifact compatibility assertion to verify the underlying inspectable descriptor without depending on a particular lazy-wrapper shape.
  • Document complete-record render-scope semantics and update the strict-port integration matcher for modern Rsbuild diagnostics.

Validation

  • Complete Octane development and production core suites: 780 files / 10,346 tests passed, with zero failures or unhandled errors.
  • Expanded TSX/TSRX scoped-JSX review matrix: 604/604 passed across client rendering, SSR, hydration, descriptor inspection, Provider updates, ErrorBoundary, and Suspense.
  • Frozen-AST/source-map/compiler compatibility coverage: 464/464 passed; universal/custom renderer coverage: 234/234 passed.
  • Representative app-core, i18next client/server, Visx SSR, and Lynx ecosystem integrations: 364/364 passed.
  • Complete repository Prettier check; Octane runtime/public type tests; app-core typecheck; changeset, generated-error-code, test-marker, published-TSRX-declaration, and package-inventory gates.
  • Octane production package build and generated client/server declaration/import smoke tests, including both createScopedValue exports.
  • Deterministic 16-file production-codegen corpus remains byte-for-byte unchanged from the previous PR head: 146,802 raw / 72,459 minified / 26,150 gzip bytes.
  • Paired ordinary-element runtime microbenchmark is unchanged within noise; the new helper increases compressed runtime size by approximately 141 client bytes / 96 server bytes and applies only to dynamic value-position root records.
  • Reproduced the real strict occupied-port Rsbuild failure and verified the previous matcher rejects its current message while the replacement matcher accepts it; full package-build/browser jobs remain covered by GitHub Actions because optional local dependencies/Chromium are absent.
  • Confirmed this branch and the independent runtime-performance PR perf(octane): bring JSX keyed-list rendering closer to TSRX #363 merge automatically without conflicts, despite five independently edited core files; its branch and worktree were left untouched.

Risk / follow-ups

  • Dynamic value-position roots now intentionally evaluate their full record at inspection/render time rather than when the lexical JSX expression is created; static JSX, explicit createElement, and ordinary callbacks retain JavaScript evaluation timing.
  • A newly introduced lazy shell adds approximately 600 ns to first construction/resolution only for the affected uncommon dynamic-root path; steady-state ordinary element creation and the representative production-codegen corpus are unchanged.
  • Server rendering remains synchronous and subject to the engine's ultimate stack ceiling; the existing 1,000-level buffered/streaming regression coverage remains in the complete core run.
  • Optional Three, package-build, and real-browser integrations require dependencies/browser binaries not present in this isolated local worktree and will be rechecked by the PR's GitHub Actions matrix.

Follow-up to #353 and #355; addresses #353 (comment) and the latest review on #361.

@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.

@domgan-oai domgan-oai changed the title fix(octane): scope JSX values to their rendered element tree fix(octane): scope JSX values and prevent deep SSR stack overflows Jul 28, 2026
Comment thread packages/octane/src/runtime.ts Resolved
@vercel

vercel Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
octane-website Ready Ready Preview, Comment Jul 28, 2026 10:44pm
octane-website-mcp Ready Ready Preview, Comment Jul 28, 2026 10:44pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 28, 2026 21:29 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 28, 2026 21:29 Inactive
Comment thread packages/octane/src/compiler/compile.js Resolved
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 28, 2026 21:54 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 28, 2026 21:55 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 28, 2026 22:10 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 28, 2026 22:11 Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 9a5c0e2. Configure here.

Comment thread packages/octane/src/compiler/compile.js Resolved
@GabbeV

GabbeV commented Jul 28, 2026

Copy link
Copy Markdown

One remaining concern: root type and props are still evaluated when the JSX value is created, while descendant construction is deferred.

const value = (
  <Outer foo={readA()}>
    <Inner bar={readB()} />
  </Outer>
);

Here readA() is eager, but readB() runs in the represented render scope.

Would it be cleaner to defer the complete compiler-authored element record instead? For users who never inspect element objects, which is the normal and encouraged usage, JSX values would then have one simple semantic: the whole tree evaluates where it is rendered, with no root-versus-descendant exception.

The less common Children, cloneElement, and direct descriptor-inspection paths could force that record in the inspector’s current scope. That seems like a better place to put the compatibility complexity than in the semantics every ordinary JSX user receives.

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 28, 2026 22:43 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 28, 2026 22:44 Inactive
@domgan-oai

Copy link
Copy Markdown
Contributor Author

@GabbeV Agreed—the root/descendant split was the wrong semantic boundary. This is addressed in 4892d3f: dynamic root component types, root props/getters/spreads, and descendant construction now resolve together in the element’s represented render scope.

The less common descriptor-inspection paths (Children.only, cloneElement, and direct .type/.props/.children access) force that record in the inspector’s current scope, while static JSX and explicit createElement(...) retain their existing fast paths.

I also added mirrored TSX/TSRX development/production coverage for direct-return SSR, hydration, root attributes/spreads/component props/tags, provider updates, shared descriptors, ErrorBoundary, and Suspense: 604 focused cases pass, as does the complete 10,346-test suite. The fixed 16-file production-codegen corpus remains byte-for-byte unchanged.

@trueadm
trueadm merged commit 3aada64 into octanejs:main Jul 28, 2026
28 checks passed
trueadm added a commit that referenced this pull request Sep 28, 2026
Compiler-authored JSX values defer their non-literal props and children to
the represented render scope (#361). The divergence doc framed this around
providers and boundaries, but it also covers host-only markup, so a value
that exists only while the building call runs is gone at render time. A
Lexical DecoratorNode whose decorate() returns <span>{this.getLabel()}</span>
throws in $getState because the label is read after Lexical's editor state
is no longer active.

Document the consequence with the Lexical example and the fixes: read the
value into a local, use createElement, or read from a component. Pin all
three forms in scoped-jsx-values for TSRX and TSX on client and server.

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

2 inactive deployments
Preview – octane-website — 4892d3f8 Deployed Jul 28, 2026 by vercel[bot]
Preview – octane-website-mcp — 4892d3f8 Deployed Jul 28, 2026 by vercel[bot]
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.

3 participants