Skip to content

Port TanStack Start in-repo as @octanejs/tanstack-start - #168

Merged
trueadm merged 9 commits into
mainfrom
claude/tanstack-start-binding
Jul 18, 2026
Merged

trueadm merged 9 commits into
mainfrom
claude/tanstack-start-binding

Conversation

@trueadm

@trueadm trueadm commented Jul 18, 2026 •

Copy link
Copy Markdown
Collaborator

Why

website/package.json pinned @tanstack/octane-start (and @tanstack/octane-router) to pkg.pr.new preview URLs whose own dependencies are also URL-resolved. pnpm 11's blockExoticSubdeps skips deps already in the lockfile but re-fires whenever the workspace importer set changes — so adding any new workspace package failed pnpm install with ERR_PNPM_EXOTIC_SUBDEP (this is what parked examples/harbor). This PR removes every URL dependency while keeping the supply-chain protection enabled — and then moves the whole website stream path onto octane's native SSR injection API (#169 + this PR's document mode), deleting TanStack's byte-level HTML re-parse for octane.

What

1. TanStack Start ported in-repo

  • Vendor the 7 packages that exist only on TanStack's unmerged octane PR branch (commit 753f919e): octane-router, octane-start, octane-start-client, octane-start-server, router-generator, router-plugin, start-plugin-core — under packages/tanstack-start/vendor/* as private workspace packages keeping their upstream @tanstack/* names (the start compiler and route-tree generator hardcode those specifiers). URL deps rewritten to workspace:* / exact registry versions — the remaining 8 @tanstack/* deps were diff-proved byte-identical to their same-numbered npm releases. Prebuilt vendor dist/ trees are committed via a .gitignore exemption (the global dist ignore silently dropped them at first — the Vercel deploy failure).
  • @octanejs/tanstack-start — the first-party facade the website consumes: Node-native .js re-export entries plus a plugin wrapper owning the workspace-source optimizeDeps handling: excludes for the start runtime chain (prebundled chunks bypass the start compiler's per-environment stripping → AsyncLocalStorage in the browser) and includes for octane-router's registry subpaths (request-time discovery of raw-source imports otherwise triggers vite's mid-session optimize full page reload under a hydrating page).
  • Website: plugin import switches to @octanejs/tanstack-start/plugin/vite; all deps become workspace:*; routeTree.gen.ts stays byte-stable. No status.json deliberately — the repo contract ties it to publishable bindings (README carries the status).

2. Streaming document mode in octane + Start on the native injection path

  • octane document mode (engages only when a StreamOptions.injection source is present and the shell renders a document): the response leads with <!DOCTYPE html>; renderer-owned leading scoped styles and the hoisted-head buffer fold inside the authored <head>; the held </body></html> tail closes the stream only once rendering is complete and the source's done settles. StreamInjectionSource gains an optional renderComplete() hook (fired exactly once — success or degraded abort/error path) so sources can finalize asynchronous serialization. Without injection, streamed output is byte-identical (pinned by a control test, flat on the streaming-ssr bench).
  • Vendored renderRouterToStream rewritten onto the native API: serverSsr wires take/subscribe/done/renderComplete (script barrier lifts at octane's post-shell subscribe; upstream's serialization timeout preserved), deleting transformStreamWithRouter, relocateLeadingOctaneStylesToHead, and prependDoctype from the stream path. This also restores out-of-order suspense streaming for document renders — the upstream transform entered tail-holding on octane's first chunk and buffered every subsequent chunk into a 64 KiB-capped tail until both streams ended.

Testing

  • pnpm install green with blockExoticSubdeps active; zero pkg.pr.new references in any package.json or the lockfile.
  • packages/octane/tests/streaming-ssr-injection.test.ts: 12 contract cases × both compile modes (ordering/chunk boundaries, done-gated close, doctype, head folding, renderComplete on success and abort, no-injection byte-shape control).
  • Website ssr-hydration.e2e.test.ts: 32/32 on a cold vite cache — real dev server + production octane-preview, every route, headless Chromium, on the native injection path.
  • Repo gates: full suite 11298 passed (one unrelated deferred-hydration flake under full-suite load; 42/42 in isolation), typecheck, format:check, changeset:check, bindings:status:check green. streaming-ssr bench flat for the no-injection path (no regression; no improvement claimed).

Notes

  • Merge Streaming SSR: native external-HTML injection (StreamOptions.injection) #169 first (already on main) — this branch contains it via merge.
  • Once this merges, examples/harbor rebases onto it and its pnpm install unblocks.
  • The native-path renderRouterToStream is the natural artifact to upstream to TanStack (their transform currently disables out-of-order streaming for octane document renders and caps segment volume at 64 KiB).
  • When TanStack's octane PR lands on npm, vendor/ can be deleted and the facade repointed at registry deps (see packages/tanstack-start/README.md).

🤖 Generated with Claude Code


Note

Medium Risk
Touches core SSR streaming and closes the response only after injection done, but the no-injection path stays byte-identical and the change is covered by contract and website e2e tests.

Overview
Adds streaming SSR document mode in octane when StreamOptions.injection is set and the shell is a full document: the stream starts with <!DOCTYPE html>, leading scoped styles and the hoisted-head buffer move into the authored <head>, and the closing </body></html> tail is held until rendering finishes and the injection source’s done settles. StreamInjectionSource gains optional renderComplete() (once per render, including abort/error) so sources can flush async serialization; degraded closes salvage queued injection HTML after unsubscribe.

Introduces @octanejs/tanstack-start, vendoring the seven PR-only @tanstack/octane-* packages (with committed dist/ and gitignore/prettier exceptions) and a Vite plugin wrapper that keeps the Start runtime chain source-served via optimizeDeps excludes/includes. Vendored renderRouterToStream merges router data through native injection instead of transformStreamWithRouter / doctype / style-relocation transforms, restoring out-of-order Suspense chunks for document SSR.

Docs, changeset, and eval lockfile hashes are updated; contract tests cover document mode and failure salvage.

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

Removes the website's pkg.pr.new URL dependencies, which made pnpm install
fail with ERR_PNPM_EXOTIC_SUBDEP whenever any new workspace package was
added (pnpm 11 blockExoticSubdeps re-fires when the importer set changes).
The protection stays enabled; the root cause is gone.

- Vendor the seven packages that exist only on TanStack's unmerged octane
  PR branch (commit 753f919e) verbatim under
  packages/tanstack-start/vendor/* as private workspace packages KEEPING
  their upstream @tanstack/* names — the start compiler and route-tree
  generator hardcode those import specifiers. URL deps rewritten to
  workspace:* (vendored siblings) or exact registry versions (the eight
  remaining @TanStack deps verified byte-identical to their same-numbered
  npm releases; history's only delta is an internal microtask refactor).
- Add @octanejs/tanstack-start, the first-party facade: Node-native .js
  re-export entries over the vendored octane-start, plus a plugin wrapper
  that appends the workspace-source optimizeDeps excludes (prebundled dep
  chunks bypass the start compiler's per-environment stripping and would
  execute AsyncLocalStorage in the browser).
- Switch website to the facade (vite.config plugin import + workspace:*
  deps); routeTree.gen.ts stays byte-stable.
- Regenerate docs/packages.md and the evals user-app corpus (its
  environment pins the lockfile hash); prettier-ignore vendor/.

Gates: pnpm install green with blockExoticSubdeps active; website build +
30/30 ssr-hydration e2e (dev + production preview); full suite 11253
passed; typecheck; format:check.

Once merged, examples/harbor (worktree ../octane-harbor) rebases onto
this and its pnpm install unblocks.

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

vercel Bot commented Jul 18, 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 18, 2026 11:47pm
octane-website-mcp Ready Ready Preview, Comment Jul 18, 2026 11:47pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website July 18, 2026 22:44 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 18, 2026 22:44 Inactive
…ed SSR

Frameworks like TanStack Start merge a data stream (<script> tags
materializing as loaders settle) into the render stream by decoding the
byte stream and re-parsing it for safe insertion points, holding the
document tail in bounded text buffers. Octane's streaming engine already
emits tag-complete chunks and knows the document tail at generation time,
so the merge is now first-class:

- StreamInjectionSource { take(), subscribe(notify), done } on
  StreamOptions (octane/server). Injected HTML is emitted verbatim, in
  push order, each drain as its own transport chunk strictly BETWEEN
  renderer chunks — never before the shell. A single serialized write
  chain gives out-of-band notify drains and wave-loop writes a total
  order; every hook no-ops when the option is absent (measured flat on
  the streaming-ssr bench).
- Document renders hold the closing tail (`</body>` + interleaved block
  markers + `</html>`, detected once by suffix) and write it last;
  injected chunks and streamed Suspense segments land inside <body>. The
  stream closes only when rendering is complete AND `done` settles, so
  late data scripts are never dropped. `done` rejection and abort route
  through the existing degraded terminal path, still emitting the tail.
- Docs: docs/ssr.md section; design + remaining phases in
  docs/ssr-stream-injection-plan.md (styles-in-head, auto-doctype, and
  moving @octanejs/tanstack-start's vendored stream path onto this API —
  the upstream transform currently buffers every post-shell chunk into a
  64KiB-capped tail for document renders, so adopting this also restores
  out-of-order streaming).

Contract tests: packages/octane/tests/streaming-ssr-injection.test.ts
(8 cases, red before the implementation), green in both the octane and
octane-prod projects; full octane suites 7814 passed; typecheck + format.

Co-Authored-By: Claude Fable 5 <[email protected]>
trueadm and others added 2 commits July 18, 2026 23:56
The global `dist` gitignore silently excluded the vendored packages' dist
directories from the port commit — local runs passed off the untracked
files, but fresh clones (Vercel, CI) resolved into missing modules.
Exempt vendor dist from the ignore and commit the 548 prebuilt files.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 18, 2026 22:57 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 18, 2026 22:58 Inactive
trueadm and others added 2 commits July 19, 2026 00:00
…duction)

Conflict: regenerated the evals user-app corpus manifest against the merged lockfile.

Co-Authored-By: Claude Fable 5 <[email protected]>
Completes the remaining phases of docs/ssr-stream-injection-plan.md so the
website streams through octane's native injection API instead of TanStack's
byte-level HTML re-parse:

- octane document mode (engages only when a StreamOptions.injection source
  is present and the shell renders a document): the response leads with
  <!DOCTYPE html>; renderer-owned leading scoped styles and the hoisted-head
  buffer fold inside the authored <head> instead of preceding <html>; the
  held </body></html> tail closes the stream. StreamInjectionSource gains an
  optional renderComplete() hook — fired exactly once when rendering
  finishes (success or degraded abort/error) so sources can finalize
  asynchronous serialization and then settle done.
- vendored @tanstack/octane-router renderRouterToStream rewritten onto the
  native API: serverSsr wires take/subscribe/done/renderComplete (barrier
  lifts at octane's post-shell subscribe; upstream's serialization timeout
  preserved), deleting transformStreamWithRouter,
  relocateLeadingOctaneStylesToHead, and prependDoctype from the stream
  path. This also restores out-of-order suspense streaming for document
  renders — the upstream transform buffered every post-shell chunk into a
  64KiB-capped tail until both streams ended.
- @octanejs/tanstack-start plugin pre-declares the octane-router registry
  subpaths (router-core/isServer, scroll-restoration-script) so request-time
  discovery can't trigger vite's mid-session optimize reload under a
  hydrating page.

Evidence: streaming-ssr-injection contract tests extended to 12 cases (both
compile modes, incl. doctype/head-folding/renderComplete pins and the
no-injection byte-shape control); website ssr-hydration e2e 32/32 on a cold
vite cache (dev + production preview) on the native path; full suite 11298
passed (one unrelated deferred-hydration flake under load, 42/42 in
isolation); typecheck, format, changeset checks green; streaming-ssr bench
flat for the no-injection path.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 18, 2026 23:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 18, 2026 23:27 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 acf0cce. Configure here.

Comment thread packages/octane/src/runtime.server.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 18, 2026 23:32 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 18, 2026 23:32 Inactive
The workspace validator requires a status.json for every @octanejs/*-named
package it classifies as a framework binding — but status.json also feeds
the public bindings catalog (website-mcp globs every one; bindings.json must
list exactly the non-private bindings), which a private, unpublished facade
must stay out of. The Start facade is a metaframework integration, not a
library binding: give it the same SPECIAL_ROLES classification as
@octanejs/vite-plugin and regenerate docs/packages.md.

Verified the entire CI lint-job step list locally (format, rules, changesets,
test markers, parity gaps, react-parity, package inventory, binding parity,
bindings-status, lucide, octane build + dist verification) plus the
publishable-package pack canaries.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 18, 2026 23:38 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 18, 2026 23:39 Inactive
Bugbot review finding on #168: the abort/error and done-rejection paths
wrote the degraded terminal chunk (recovery markers + held document tail)
without a final take(), dropping HTML the source queued during its
renderComplete finalization — the success path drains, so degraded closes
silently lost the serialization remainder.

Both fatal paths now unsubscribe FIRST (a notify fired by the finalization
would otherwise drain the queue into a chained write that post-abort can
only reject), then salvage a direct take() into the terminal write ahead of
the recovery markers and the held tail. Two regression tests with verified
pre-fix failures pin the salvage on each path.

Co-Authored-By: Claude Fable 5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 18, 2026 23:46 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 18, 2026 23:47 Inactive
@trueadm
trueadm merged commit 2932a23 into main Jul 18, 2026
21 checks passed
@trueadm
trueadm deleted the claude/tanstack-start-binding branch July 18, 2026 23:53

This branch was previously deployed

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