SSR build: two chunks import each other, and a `var` is read before its chunk assigns it, so every server render fails (TanStack Start, node-server)
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- node.js, typescript, vite
- Domain
- backend, build-system
Research direction
Start by tracing the server build configuration for the default node-server preset and how Nitro invokes Rolldown for SSR chunks. Check whether that build sets strictExecutionOrder, using issues #4605 and #4533 as related context. Done when the reported mutually importing chunks preserve initialization order and the affected server render succeeds; the issue does not name a test or a reduced reproduction.
Written by the indexing model from the issue text.
Description
Environment
- nitro 3.0.260903-beta (npm
lateston 2026-10-13), Nitro's rolldown 1.2.13 - vite 8.2.2
- @tanstack/react-start 1.168.61, @tanstack/react-router 1.170.42
- Build on Node 24.14.1 (macOS arm64); runs in
node:24-bookworm-slim - Preset: default (
node-server) - Config:
nitro({ plugins: ['./src/nitro-startup.ts'] })
Reproduction
The app is private and I have not reduced it to a small public repository
yet. The two chunks and the lines that matter are below.
Describe the bug
vite build succeeds and the server starts with no error. .output/server/_ssr/
has two chunks that import each other:
router-BFTpZbpG2.mjs:20:import { router_exports } from "./router-BFTpZbpG.mjs";(and re-exportsrouter_exports)router-BFTpZbpG.mjs:81:import { …, ServiceDeskIcon, … } from "./router-BFTpZbpG2.mjs";
The SSR entry loads router-BFTpZbpG2.mjs first (ssr.mjs:8690,
import("./router-BFTpZbpG2.mjs").then((n) => n.router_exports)). ESM runs its dependency
router-BFTpZbpG.mjs first, and that chunk's import back from
router-BFTpZbpG2.mjs is the cycle, so it runs before
router-BFTpZbpG2.mjs:1094 has run:
var ServiceDeskIcon = sidebarIcon("ServiceDesk", …)
router-BFTpZbpG.mjs:3171 then stores the binding's value, which is still
undefined (a var, so no error is thrown):
var SERVICE_DESK = { id: "service-desk", label: "Service Desk", icon: ServiceDeskIcon, Nav: ServiceDeskNav };
The value stays undefined for the life of the process, and React throws on
every server render that draws it:
Error in renderToReadableStream: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
There is no cycle in the source. The module that defines ServiceDeskIcon
imports only React's types and a cn helper. A Node script that imports the
built router_exports and reads each route's product finds every icon
undefined.
inlineDynamicImports: true fixes it (one server file, each module runs its
imports first).
Additional context
Possibly related: #4605 (helpers placed after their first use in an SSR
chunk) and #4533 (an SSR chunk exports an undeclared name; same workaround).
Rolldown's docs say automatic code splitting "sometimes places modules
without respecting their original order"; Rolldown's strictExecutionOrder
addresses that, but Nitro does not set it for the server build.
- Dominant language
- TypeScript
- Stars
- 11.5k
- Forks
- 968
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 64
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
pending triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 2 days
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configPossibly taken @draarivpatel-ui claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
pending triage
Difficulty 5/5 Over a week Newbie friendliness 30/100
nitrojs/nitro#5205 · 1 reaction ·
Maintainers usually reply within 2 days
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranxianglei/billion-context#8319 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JimLiu/open-artifact#126 ·
-
bug repro-ready
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
mksglu/context-mode#1454 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
laststance/design-world#98 ·
Maintainers usually reply within 1 day
-
Add: KCM True crimeOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day