TanStack / TanStack/router

Start: Can't build with cloudflare + prerender enabled

Open
#6,330 10 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Start

Describe the bug

with

    tanstackStart({
      prerender: {
        enabled: true,
      },
    }),

in the root dir, run pnpm build --force, has the error

But the following works:

  1. If don't use turbo, run cd apps/web && pnpm build, works
  2. If use turbo
    i) in the root dir, run CI=true pnpm build --force, works

The error when run pnpm build is

 ~/Github/monorepo-tanstarter  main ................................ base py  system node  16:57:05 
> pnpm build --force

> monorepo-tanstarter@ build /Users/leonz/Github/monorepo-tanstarter
> turbo run build --force

• turbo 2.7.3
• Packages in scope: @read-frog/web
• Running build in 1 packages
• Remote caching disabled
┌─ @read-frog/web#build > cache bypass, force executing 7eb28853d3068e90 


> @read-frog/web@0.0.0 build /Users/leonz/Github/monorepo-tanstarter/apps/we
b
> vite build && tsc --noEmit

...
✓ built in 532ms
[prerender] Prerendering pages...
[prerender] Concurrency: 14
[prerender] Crawling: /
[prerender] Prerendered 0 pages:
file:///Users/leonz/Github/monorepo-tanstarter/node_modules/.pnpm/@tanstack+
start-plugin-core@1.145.3_@tanstack+react-router@1.144.0_react-dom@19.2.3_re
a_a885d342423b94b4b456f798ea19fe84/node_modules/@tanstack/start-plugin-core/
dist/esm/prerender.js:126
            throw new Error(`Failed to fetch ${page.path}: ${res.statusText}
`, {
                  ^

Error: Failed to fetch /: Internal Server Error
    at file:///Users/leonz/Github/monorepo-tanstarter/node_modules/.pnpm/@ta
nstack+start-plugin-core@1.145.3_@tanstack+react-router@1.144.0_react-dom@19
.2.3_rea_a885d342423b94b4b456f798ea19fe84/node_modules/@tanstack/start-plugi
n-core/dist/esm/prerender.js:126:19
    at process.processTicksAndRejections (node:internal/process/task_queues:
103:5)
    at async file:///Users/leonz/Github/monorepo-tanstarter/node_modules/.pn
pm/@tanstack+start-plugin-core@1.145.3_@tanstack+react-router@1.144.0_react-
dom@19.2.3_rea_a885d342423b94b4b456f798ea19fe84/node_modules/@tanstack/start
-plugin-core/dist/esm/queue.js:38:17 {
  [cause]: Response {}
}

Node.js v24.12.0
 ELIFECYCLE  Command failed with exit code 1.
command finished with error: command (/Users/leonz/Github/monorepo-tanstarte
r/apps/web) /Users/leonz/Library/pnpm/.tools/pnpm/10.27.0/bin/pnpm run build
 exited (1)
└─ @read-frog/web#build ──
@read-frog/web#build: command (/Users/leonz/Github/monorepo-tanstarter/apps/web) /Users/leonz/Library/pnpm/.tools/pnpm/10.27.0/bin/pnpm run build exited (1)

 Tasks:    0 successful, 1 total
Cached:    0 cached, 1 total
  Time:    2.96s 
Failed:    @read-frog/web#build

 ERROR  run failed: command  exited (1)
 ELIFECYCLE  Command failed with exit code 1.
Your Example Website or App

https://github.com/ananaBMaster/monorepo-tanstarter

Steps to Reproduce the Bug or Issue
  1. clone https://github.com/ananaBMaster/monorepo-tanstarter
  2. pnpm i
  3. pnpm build --force
Expected behavior

no error when pnpm build

Screenshots or Videos

No response

Platform
> turbo info
• turbo 2.7.4-canary.1
CLI:
   Version: 2.7.4-canary.1
   Path to executable: /Users/leonz/Github/monorepo-tanstarter/node_modules/.pnpm/turbo-darwin-arm64@2.7.4-canary.1/node_modules/turbo-darwin-arm64/bin/turbo
   Daemon status: Running
   Package manager: pnpm9

Platform:
   Architecture: aarch64
   Operating system: macos
   WSL: false
   Available memory (MB): 4466
   Available CPU cores: 14

Environment:
   CI: None
   Terminal (TERM): xterm-256color
   Terminal program (TERM_PROGRAM): vscode
   Terminal program version (TERM_PROGRAM_VERSION): 2.0.34
   Shell (SHELL): /bin/zsh
   stdin: false
Additional context

No response

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

Start with apps/web/vite.config.ts and the root package build script, then compare the pnpm build --force paths with the direct apps/web build and CI=true behavior. Trace the prerender step that crawls / and fails with an Internal Server Error; done means the documented reproduction completes successfully from the repository root.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.