Skip to content

start-plugin-core: instanceof RunnableDevEnvironment fails with vite-plus alias (dual-package hazard) #6982

@CETE0

Description

@CETE0

Problem

@tanstack/start-plugin-core's dev server plugin uses isRunnableDevEnvironment(serverEnv) (which calls instanceof) to guard SSR middleware registration at src/dev-server-plugin/plugin.ts line ~147.

When vite is aliased to another package via pnpm overrides (e.g. vite: npm:@voidzero-dev/vite-plus-core@latest), two different RunnableDevEnvironment class references exist in memory — instanceof returns false, SSR middleware is never registered, and all routes return 404.

This is a dual-package hazard.

Reproduction

  1. Create a TanStack Start project
  2. Add pnpm override: "vite": "npm:@voidzero-dev/vite-plus-core@latest"
  3. Run pnpm dev
  4. All routes return 404 "Cannot GET /"

Suggested Fix

Replace instanceof with duck-typing in plugin.ts:

- if (!isRunnableDevEnvironment(serverEnv) || "dispatchFetch" in serverEnv) {
+ if (!("runner" in serverEnv) || "dispatchFetch" in serverEnv) {

The runner property (a public getter) is unique to RunnableDevEnvironmentFetchableDevEnvironment and DevEnvironment don't have it. The existing "dispatchFetch" in serverEnv guard correctly handles Nitro.

Versions

  • @tanstack/start-plugin-core: 1.166.8
  • vite-plus / @voidzero-dev/vite-plus-core: 0.1.12 (Vite 8.0.0)

Workaround

pnpm patch @tanstack/start-plugin-core with the diff above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions