Start SSR bundle calls createServerFn before initialization with pnpm symlinked layout

Aperta
#8,139 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript, vite

Direzione di ricerca

Inizia con il riproduttore minimo e confronta le installazioni symlinked e hoisted usando i comandi pnpm build e preview indicati. Ispeziona src/schema.ts e il relativo import in src/data.ts, quindi segui la build Vite intermedia di Nitro fino a .output/server/_ssr/ssr.mjs. Il lavoro è completato quando il layout symlinked serve HTTP 200 senza chiamare createServerFn prima dell’inizializzazione, oppure quando la build segnala chiaramente un errore.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Which project does this relate to?

Start

Describe the bug

A small TanStack Start SSR app builds successfully but returns HTTP 500 on every
request when installed with pnpm's default symlinked node_modules layout. The
emitted .output/server/_ssr/ssr.mjs invokes createServerFn before its
assignment:

TypeError: createServerFn is not a function
    at .output/server/_ssr/ssr.mjs:40:18

The same source and exact dependency versions return HTTP 200 when installed
with a hoisted layout. The trigger is importing a Drizzle pgTable schema into
the server-function/query graph. Removing that schema import also makes the
symlinked build work.

The divergence begins in Nitro's intermediate Vite build:

Install Layout HTTP Intermediate SSR entry Final ssr.mjs
pnpm install symlinked 500 247.04 kB 242.49 kB
pnpm install --config.node-linker=hoisted hoisted 200 66.89 kB 64.72 kB

This was independently controlled with Bun as well: Bun's isolated layout has
the same failure and its hoisted layout succeeds. Because pnpm reproduces the
failure without Bun, the behavior follows the dependency layout and appears to
be in the TanStack Start / Nitro bundling pipeline.

Complete minimal reproducer

https://github.com/astelmach20/tanstack-start-symlink-layout-repro

The repository contains no application code, credentials, or private
dependencies. A database is not required; the module fails during SSR startup
before the sample database URL can be used.

Steps to reproduce
git clone https://github.com/astelmach20/tanstack-start-symlink-layout-repro.git
cd tanstack-start-symlink-layout-repro
corepack enable
pnpm install --frozen-lockfile
pnpm build
pnpm preview
curl -i http://127.0.0.1:4173/

The build exits 0, then the request returns HTTP 500 with
createServerFn is not a function.

Hoisted control from a second clean clone:

pnpm install --frozen-lockfile --config.node-linker=hoisted
pnpm build
pnpm preview --port 4174
curl -i http://127.0.0.1:4174/

This returns HTTP 200.

Expected behavior

The generated SSR bundle should preserve module initialization order under
pnpm's supported default layout, or the build should fail instead of emitting a
bundle that cannot serve a request.

Platform
  • @tanstack/react-start: 1.168.28
  • @tanstack/react-router: 1.170.18
  • @tanstack/react-router-ssr-query: 1.167.1
  • @tanstack/react-query: 5.101.2
  • nitro: 3.0.260610-beta
  • vite: 8.1.5
  • drizzle-orm: 0.45.2
  • postgres: 3.4.9
  • react / react-dom: 19.2.7
  • pnpm: 10.17.1
  • Node: 23.7.0
  • OS: macOS arm64; the equivalent isolated-layout failure was also observed in
    a Linux serverless runtime
  • Bundler: Vite / Nitro (node-server preset)
Additional context
Lingua principale
TypeScript
Stelle
15.3k
Fork
1.9k
Merge medio
1g 5h
PR unite (30g)
46

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/router

Tutte le issue di TanStack/router

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.