Skip to content

nitro + spa mode breaks since v1.138.0 #5967

@ImSingee

Description

@ImSingee

Which project does this relate to?

Start

Describe the bug

If you use nitro + spa mode, the vite build will report this error:

✓ built in 535ms
[prerender] Prerendering pages...
error during build:
Error: Failed to start the Vite preview server for prerendering
    at startPreviewServer (file:///project-dir/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:195:11)
    at async prerender (file:///project-dir/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:42:25)
    at async postServerBuild (file:///project-dir/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/post-server-build.js:38:5)
    at async BasicMinimalPluginContext.handler (file:///project-dir/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:267:11)
    at async Object.buildApp (file:///project-dir/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/config.js:34542:5)
    at async CAC.<anonymous> (file:///project-dir/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/cli.js:629:3)                                                                                                                                                                  
 ELIFECYCLE  Command failed with exit code 1.

Your Example Website or App

https://github.com/ImSingee/tanstack-start-bug-reproduce-for-spa

Steps to Reproduce the Bug or Issue

  1. Setup nitro with tanstack start (https://tanstack.com/start/latest/docs/framework/react/guide/hosting#nitro)
  2. Enable SPA mode (https://tanstack.com/start/latest/docs/framework/react/guide/spa-mode)

Expected behavior

Build should be success

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.139.6
  • OS: macOS
  • Bundler: vite
  • Bundler Version: ^7.2.4

Additional context

I created a bug-reproduce repo with the latest version, but I can confirm the issue starts at v1.138.0 after #5921 is merged.

After executing the pnpm build (failed), then execute npx vite preview, this error occurs:

error when starting preview server:
Error: Cannot load nitro build info. Make sure to build first.
    at BasicMinimalPluginContext.error (file:///project-dir/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/config.js:29511:35)
    at BasicMinimalPluginContext.configurePreviewServer (file:///project-dir/node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/nitro/dist/_build/vite.plugin.mjs:443:31)
    at async preview (file:///project-dir/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/config.js:35765:93)
    at async CAC.<anonymous> (file:///project-dir/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/cli.js:669:18)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions