Skip to content

Add the TanStack Start benchmark (Octane vs React) + two compiler fixes it surfaced - #197

Merged
trueadm merged 7 commits into
mainfrom
claude/tanstack-start-bench
Jul 20, 2026
Merged

trueadm merged 7 commits into
mainfrom
claude/tanstack-start-bench

Conversation

@trueadm

@trueadm trueadm commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

What

benchmarks/tanstack-start: one Start application, built and served twice — the repo's vendored @tanstack/octane-start (native StreamOptions.injection stream path, nitro output) versus @tanstack/react-start from npm, pinned to the same release family as the vendored packages (react-start 1.168.28, react-router 1.170.18, minimal srvx server). Both apps derive from TanStack's own MIT-licensed e2e pair at 753f919e, trimmed to one canonical start-basic surface (/, /posts, /posts/$postId, a 404 post, /deferred) over a shared deterministic data fixture — no network anywhere.

Correctness gates (the point of Phase 1 — perf refuses to exist until these are green)

  • compare.mjs — structural: 5/5 routes PASS. Fetches every route from both production servers, strips each framework's dialect (hydration markers, framework scripts/attributes, head ordering, octane's #__app container), and requires the remaining element tree + text to match node-for-node (75+ nodes deep on the posts routes).
  • e2e/bench.spec.ts — behavioral: 8/8. One Playwright spec, two projects, identical assertions against both servers with a clean-console gate: hydration, loader/params navigation, streamed deferred resolution, not-found routing.

Two real octane compiler bugs the build surfaced — fixed with red/green regression tests

  1. Component hoisting: function X() @{…} compiled to a TDZ const, so the canonical route-file shape (createFileRoute(...)({ component: Home }) above the declaration — which TanStack's own octane e2e app uses) crashed at module evaluation, and production swallowed it into empty marker output. Components referenced above their declaration now emit real hoisted function declarations in both compile modes, with capability stamps as typeof-guarded statements (guarded because TanStack's code-splitter extracts the declaration and would strand unguarded stamps into ReferenceErrors — found by this suite's own e2e). Unreferenced components keep the PURE const form, so tree-shaking is unaffected.
  2. Volar template-body markers: @tsrx/core stopped stamping metadata.native_tsrx_body on the parse AST, silently no-op'ing the route-generator masker that TanStack's octane flavor uses — route-tree regeneration over .tsrx crashed babel on @{. Invisible until now because every existing app commits routeTree.gen.ts. markNativeTemplateBodies restores the contract (pinned in volar.test.ts), which also protects Add framework adapter TanStack/router#7847's future octane upgrade.

The 8th journey — closed by main

The initially-open octane bug (client child-navigation /posts → /posts/3 remounting the whole match tree) turned out to be the passthrough-hydration remount defect fixed independently on main (#192): after merging main, all 8 journeys pass and remount-probe.mjs confirms byte-identical DOM-identity preservation on both flavors. The committed probes stay as regression tooling. The perf phase (run.mjs + bench.mjs registration) is now unblocked and follows as its own PR.

Testing

  • Full suite 11620 passed, zero failures (both compile modes — including the loader-compatibility regression the first emission draft caused and this suite caught).
  • pnpm typecheck, format:check, changeset:check green; evals corpus regenerated for the lockfile change.
  • Bench gates as above: compare 5/5, e2e 8/8, DOM-identity probe identical across flavors.

🤖 Generated with Claude Code


Note

Medium Risk
Compiler emission changes affect all .tsrx route modules and SSR/client parity; benchmark and test coverage mitigate, but hoisting/HMR edge cases could still affect production bundles.

Overview
Adds benchmarks/tanstack-start: the same TanStack Start app built twice (vendored octane-start + nitro vs pinned react-start + srvx), with compare.mjs (normalized HTML parity on five routes), shared Playwright e2e (octane + react projects), serve-both.mjs, and remount probes. Ignores .output at the repo root.

Octane compiler (patch): When a component name is referenced above its function … @{…} declaration (typical createFileRoute({ component: Home }) before function Home), client and server compiles now emit a hoisted function declaration instead of a TDZ const, with typeof-guarded follow-ups for __warm, HMR, and single-root stamps so route code-splitting cannot leave stranded mutations. Names only in strings stay on the PURE const path.

Volar: compileToVolarMappings again sets metadata.native_tsrx_body on native template bodies in sourceAst for TanStack’s route-generator masker. Regression coverage in component-hoisting.test.ts and volar.test.ts; evals manifest overlayLockfileHash updated.

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

trueadm and others added 2 commits July 20, 2026 11:29
…ody markers

Two fixes surfaced by building the Start benchmark's octane flavor from
scratch (no committed routeTree.gen.ts, canonical route-file layout):

- Components referenced ABOVE their declaration — the canonical TanStack
  route-file shape, `createFileRoute(...)({ component: Home })` before
  `function Home() @{…}` — compiled to TDZ `const` bindings and crashed at
  module evaluation (production swallowed the failure into empty marker
  output). Both client and server emission now keep real hoisted function
  declarations for such components (`export function` / `export default
  function` forms for exported ones), with capability stamps
  (markSingleRoot, __warm, ABI marks, the vite HMR rebinding) as
  `typeof`-guarded follow-up statements — guarded because route
  code-splitters extract the declaration and would otherwise strand the
  stamps into ReferenceErrors. Detection strips comments first so docblock
  prose cannot force the hoisted form, and unreferenced components keep the
  PURE const initializer (tree-shaping preserved).
  Tests: component-hoisting.test.ts (+ fixture), pre-fix failure
  "Cannot access 'Card' before initialization" in both compile modes.

- compileToVolarMappings' sourceAst lost the `metadata.native_tsrx_body`
  markers (@tsrx/core now stamps only the transformed clone, reachable
  solely via metadata back-references), silently no-op'ing TanStack's
  octane route-generator masker — route-tree REGENERATION over .tsrx files
  crashed babel on `@{`. markNativeTemplateBodies re-stamps the parse tree
  (a JSXCodeBlock body IS a native template body); contract pinned in
  volar.test.ts including the `@{`→`}` span shape the masker rewrites.

Full suite 11620 passed clean.

Co-Authored-By: Claude Fable 5 <[email protected]>
One application built and served twice: the repo's vendored
@tanstack/octane-start (native stream-injection path, nitro output) vs
@tanstack/react-start from npm pinned to the SAME release family
(react-start 1.168.28 / react-router 1.170.18, srvx server). Both apps
derive from TanStack's own MIT e2e pair at 753f919e, trimmed to one
canonical start-basic surface (/, /posts, /posts/$postId, 404 post,
/deferred) over a shared deterministic fixture — no network anywhere.

Correctness gates (must pass before any perf number is trusted):
- compare.mjs: fetches every route from both production servers, strips
  each framework's dialect (hydration markers, framework scripts/attrs,
  head ordering, octane's #__app container), and requires the remaining
  element tree + text to match node for node. 5/5 routes PASS.
- e2e/bench.spec.ts: identical Playwright journeys against both servers
  with a clean-console gate. 7/8 pass.

Known issue (documented in the README, reproduced by the committed
probes): the octane flavor remounts the whole match tree on client child
navigation (/posts → /posts/3) — Match's SuspenseWrap flips
SafeFragment → Suspense because matchState.ssr === false on
client-loaded matches in the octane flavor only, while react-router
1.170.18 carries the identical condition without the flip. The perf
harness is deliberately absent until this gate is fully green.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel

vercel Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
octane-website Skipped Skipped Jul 20, 2026 11:43am
octane-website-mcp Skipped Skipped Jul 20, 2026 11:43am

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 20, 2026 10:30 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 20, 2026 10:30 Inactive
Comment thread packages/octane/src/compiler/compile.js Resolved
trueadm and others added 2 commits July 20, 2026 11:34
…dration remount fix); regenerate evals corpus

Co-Authored-By: Claude Fable 5 <[email protected]>
Build artifacts slipped into the bench commit — .output was not covered by
the root gitignore the way dist/ is. Ignore it globally and drop the
committed tree; both flavors' servers build locally via the harness.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 20, 2026 10:39 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 20, 2026 10:40 Inactive
…ared helper

- remount-dev-probe.mjs derives every path from import.meta.url instead of
  machine-local absolute paths.
- Drop the react flavor's unused upstream leftovers the trim missed
  (raw-stream-fns.ts, the shared-lib tree, and the custom server-entry
  smoke file — the flavor now uses react-start's default entry).
- playwright.config.ts imports getFreePort from serve-both.mjs instead of
  reimplementing it.

Gates re-verified: react rebuild, compare 5/5, e2e 8/8, probe runs
relative-path clean.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 20, 2026 10:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 20, 2026 10:45 Inactive
Comment thread packages/octane/src/compiler/compile.js Resolved
Comment thread packages/octane/src/compiler/compile.js Resolved
…nce detection string-blind

Two review findings on the hoisting path:

1. For exported single-root components on the early-reference path with HMR,
   the inline _$__s stamp marked the RAW function and claimed
   singleRootInitialized, suppressing the module-tail fallback — the only
   stamp that lands after the _$hmr rebind. Since hmr() forwards __warm but
   not $$singleRoot, the exported wrapper consumers saw lacked the mark.
   Now the inline stamp still covers the pre-declaration capture, but
   singleRootInitialized stays unset when a rebind follows, so the tail
   fallback stamps the wrapper too.

2. The early-reference scan stripped comments but still matched names inside
   string literals (route paths, import specifiers, messages), needlessly
   forcing the hoisted form and dropping the tree-shakeable /* @__PURE__ */
   const emission. A shared stripNonReferenceText helper now blanks plain
   strings as well, at both the client and server emission sites. Template
   literals stay intact: ${Name} interpolations are real references and
   swallowing one would reintroduce the TDZ crash hoisting prevents.

Pinned by five emission-property tests in component-hoisting.test.ts.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 20, 2026 11:01 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 20, 2026 11:02 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 20, 2026 11:42 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 20, 2026 11:42 Inactive
remount-probe.mjs mirrored the fix remount-dev-probe.mjs already had:
createRequire anchored on import.meta.url so the probe runs from any
working directory.

Co-Authored-By: Claude Fable 5 <[email protected]>
@trueadm
trueadm force-pushed the claude/tanstack-start-bench branch from 7c2ac01 to b973350 Compare July 20, 2026 11:43
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 20, 2026 11:43 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 20, 2026 11:43 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 OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b973350. Configure here.

res.setHeader('Content-Type', MIME[path.extname(file)] ?? 'application/octet-stream');
fs.createReadStream(file).pipe(res);
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Static path escapes client root

High Severity

path.join(clientDir, pathname) receives a URL pathname that always starts with /, so on POSIX the client dist root is discarded and the path is resolved from the filesystem root. The .. check does not stop absolute paths, so requests can read arbitrary local files, and intended dist/client assets are never resolved through this branch.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b973350. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This one doesn't reproduce — the described behavior is path.resolve's, not path.join's. join concatenates segments and never discards the base for an absolute second argument:

path.join('/repo/react/dist/client', '/etc/passwd')   // → /repo/react/dist/client/etc/passwd
path.resolve('/repo/react/dist/client', '/etc/passwd') // → /etc/passwd  (what the finding describes)

Verified against the running server:

  • GET /assets/deferred-BMYp9JA6.js → 200 text/javascript — client assets ARE resolved and served through this branch (they're what hydrates every e2e journey).
  • GET /etc/passwd (--path-as-is) → 404 via the Start handler's not-found page — the joined path dist/client/etc/passwd doesn't exist, so the request falls through.
  • GET /%2e%2e/%2e%2e/%2e%2e/etc/passwd → 404 — the .. check runs after decodeURIComponent, so encoded traversal is caught too.

Leaving the code as is.

@trueadm
trueadm merged commit 443bba7 into main Jul 20, 2026
22 checks passed
@trueadm
trueadm deleted the claude/tanstack-start-bench branch July 20, 2026 12:07

This branch was previously deployed

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

1 participant