Skip to content

404/Not found component not rendering on dev server #6319

@gabenddos

Description

@gabenddos

Which project does this relate to?

Start

Describe the bug

I was writing the e2e tests for my application and I noticed that in production the Not found test worked fine but when using the dev command to run the tests it was breaking on the test.

❌ vite dev:
Image

✅ But in production the component is rendering normally as it is supossed to be:
Image

  • I was using Bun, but with a brand new Node, the issue still happens.
  • The error just happens in vite dev.

  • After building the project and running with node ./output/server/index.mjs it works fine.
  • I also noticed that commenting out the nitro plugin on vite.config.ts then running vite dev the not found component starts working again.

Your Example Website or App

https://github.com/gabenddos/tanstack-start-not-found-dev-error

Steps to Reproduce the Bug or Issue

  1. Scaffolding a brand new Tanstack Start project
  2. Setup the notFoundComponent (on router or any specific route you want) e.g. src/router.tsx
const router = createRouter({
	routeTree,
	context: {
		...rqContext,
	},
	defaultNotFoundComponent: () => <div>Not Found</div>, // ADDED NOT FOUND COMPONENT
	defaultPreload: "intent",
});
  1. Runs the dev server with pnpm dev or bun dev.
  2. Access any non existing route: e.g. http://localhost:3000/non-exising-route or /lorem-ipsum, etc...
    "Cannot Get /{pathname}" instead of the actual react not found component

Expected behavior

Should render react not found component instead of a Cannot Get error page.

Screenshots or Videos

No response

Platform

  • Router / Start Version: ^1.132
  • OS: macOS
  • Browser: Chrome
  • Browser Version: 143 (latest stable)
  • Bundler: Vite
  • Bundler Version: 7.1.7

Additional context

Stack blitz does not seams to reproduce the error, please clone the repo and run locally.
Related issue: #5960 Throwing a notFound on loaders seams to have the same bahaviour described in this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions