Repository navigation
Add the TanStack Start benchmark (Octane vs React) + two compiler fixes it surfaced - #197
Conversation
…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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
…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]>
…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]>
…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]>
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]>
7c2ac01 to
b973350
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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; | ||
| } |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit b973350. Configure here.
There was a problem hiding this comment.
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→ 200text/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 pathdist/client/etc/passwddoesn't exist, so the request falls through.GET /%2e%2e/%2e%2e/%2e%2e/etc/passwd→ 404 — the..check runs afterdecodeURIComponent, so encoded traversal is caught too.
Leaving the code as is.


What
benchmarks/tanstack-start: one Start application, built and served twice — the repo's vendored@tanstack/octane-start(nativeStreamOptions.injectionstream path, nitro output) versus@tanstack/react-startfrom npm, pinned to the same release family as the vendored packages (react-start1.168.28, react-router1.170.18, minimal srvx server). Both apps derive from TanStack's own MIT-licensed e2e pair at753f919e, trimmed to one canonicalstart-basicsurface (/,/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#__appcontainer), 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
function X() @{…}compiled to a TDZconst, 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 astypeof-guarded statements (guarded because TanStack's code-splitter extracts the declaration and would strand unguarded stamps intoReferenceErrors — found by this suite's own e2e). Unreferenced components keep the PURE const form, so tree-shaking is unaffected.@tsrx/corestopped stampingmetadata.native_tsrx_bodyon the parse AST, silently no-op'ing the route-generator masker that TanStack's octane flavor uses — route-tree regeneration over.tsrxcrashed babel on@{. Invisible until now because every existing app commitsrouteTree.gen.ts.markNativeTemplateBodiesrestores the contract (pinned involar.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/3remounting 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 andremount-probe.mjsconfirms 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
pnpm typecheck,format:check,changeset:checkgreen; evals corpus regenerated for the lockfile change.compare5/5, e2e 8/8, DOM-identity probe identical across flavors.🤖 Generated with Claude Code
Note
Medium Risk
Compiler emission changes affect all
.tsrxroute 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), withcompare.mjs(normalized HTML parity on five routes), shared Playwright e2e (octane + react projects),serve-both.mjs, and remount probes. Ignores.outputat the repo root.Octane compiler (patch): When a component name is referenced above its
function … @{…}declaration (typicalcreateFileRoute({ component: Home })beforefunction Home), client and server compiles now emit a hoisted function declaration instead of a TDZconst, withtypeof-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 PUREconstpath.Volar:
compileToVolarMappingsagain setsmetadata.native_tsrx_bodyon native template bodies insourceAstfor TanStack’s route-generator masker. Regression coverage incomponent-hoisting.test.tsandvolar.test.ts; evals manifestoverlayLockfileHashupdated.Reviewed by Cursor Bugbot for commit b973350. Bugbot is set up for automated code reviews on this repo. Configure here.