nitrojs / nitrojs/nitro

Production build emits invalid `ssr_exports` reference in bundled SSR chunk (TanStack Start, any preset)

Open
#4,533 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

tanstack v3
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Summary

Building a TanStack Start app for production with any recent nitro beta produces a bundled SSR chunk that references an export (ssr_exports) which is never declared or imported in that module, causing a SyntaxError the moment the module is loaded at runtime.

Environment

  • nitro: reproduced on 3.0.260311-beta, 3.0.260603-beta, and 3.0.260610-beta (the three most recent date-stamped betas at time of writing)
  • vite: 8.2.1
  • @tanstack/react-start: 1.168.46
  • @tanstack/start-client-core: 1.170.24
  • Node: 22.22.2
  • Reproduced with both the default (node-server) preset and the vercel preset — not preset-specific.

Steps to reproduce

  1. A standard TanStack Start app using createServerFn (any number of server functions is enough — this is not specific to CSRF middleware; removing createCsrfMiddleware from src/start.ts does not avoid the bug).
  2. npm run build
  3. Inspect .output/server/_ssr/ssr.mjs (or the equivalent chunk under .vercel/output/functions/__server.func/_ssr/ when building with NITRO_PRESET=vercel).

Actual result

The generated chunk contains an export statement like:

export { getResponseHeaders as a, ssr_exports as c, createServerEntry, server_default as default, getCookies as i, createCsrfMiddleware as l, TSS_SERVER_FUNCTION as n, setCookie$1 as o, getServerFnById as r, setResponseHeader as s, createServerFn as t, createMiddleware as u };

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run npm run build with a standard TanStack Start app using createServerFn, then inspect .output/server/_ssr/ssr.mjs or the equivalent Vercel SSR chunk. Trace the generated export list and its source through the Nitro bundling path; done means the production SSR module loads without an undeclared ssr_exports reference for both node-server and vercel presets.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.