Skip to content

instanceof RunnableDevEnvironment fails with vite-plus alias #7218

Closed

Description

@ultra2207

Which project does this relate to?

Router

Describe the bug

IF you do vp dev the error occurs. It says Cannot get /. Note that using npm run dev or bun run dev which runs vite under the hood works fine.

The fix in #6982 (comment) fixes the issue.

Your Example Website or App

https://github.com/ultra2207/tanstack_test

Steps to Reproduce the Bug or Issue

  1. git clone into the reproducer
  2. Install Vite-plus
  3. Run vp dev and open the url

Expected behavior

it will show "Cannot GET /"

Screenshots or Videos

No response

Platform

When using Vite-plus cli.

Additional context

No response

Activity

  1. schiller-manuel commented on Apr 18, 2026

    @schiller-manuel
    Collaborator

    please provide a reproducer that can be cloned directly without having to execute any more installation. also try different package managers to find out if it depends on that

  2. ultra2207 commented on Apr 18, 2026

    @ultra2207
    Author

    you can clone what i linked above directly, but yeah it is an issue with vite+ specifically. Using npm or bun to start thr vite server does fine. However since the fix for the issue is in tanstack router code and not in vite-plus code i opened the issue here.

    Reproduction simply involves git cloning the above, installing vite-plus, cd into it and then do vp run.

  3. schiller-manuel commented on Apr 18, 2026

    @schiller-manuel
    Collaborator

    why dont you install vite-plus then in the repo? it might matter which package manager you use for that step.

  4. ultra2207 commented on Apr 18, 2026

    @ultra2207
    Author

    the regular vp install using irm https://vite.plus/ps1 | iex installs globally, not in the repo. Also just putting it in the repo wont work as its different for windows/mac/linux. Not to mention adding to path which the command does automatically.

  5. ultra2207 commented on Apr 19, 2026

    @ultra2207
    Author

    yo

  6. roll commented on May 26, 2026

    @roll

    It seems to be we are running into the same, a mostly empty Tanstack Start app does work with vite dev and 404 on any route with vp dev (pnpm managed)

  7. kevinkod commented on Jun 8, 2026

    @kevinkod

    Corroborating data point from a different setup (npm workspaces, not the OP's global vite-plus install), in case it helps move this out of "information needed".

    Environment

    • npm workspaces monorepo (not pnpm/bun), vite aliased to vite-plus via root overrides: "vite": "npm:@voidzero-dev/vite-plus-core@latest"
    • @tanstack/react-start SSR app, vp dev
    • Reproduces identically against [email protected], 1.168.14, and with [email protected]; also against [email protected]/0.1.21/0.1.22 and plain npx vite (vite 8.0.14). The @tanstack/* version is not the variable — the vite-plus alias is.

    Symptom: vp dev boots fine but every route returns 404 Cannot GET /. vite dev (real vite) works.

    Where it bails — start-plugin-core/dist/esm/vite/dev-server-plugin/plugin.js:

    if (installMiddleware == void 0) {
      if (viteDevServer.config.server.middlewareMode) return;
      if (!isRunnableDevEnvironment(serverEnv) || "dispatchFetch" in serverEnv) return; // ← silent bail, no log
    }

    Under the vite-plus alias the SSR environment isn't recognized as a RunnableDevEnvironment, so the dev middleware is never installed and every request 404s. Note the bail is silent — there's no warning, which is what makes this hard to diagnose. The throw a few lines down (cannot install vite dev server middleware ... not a RunnableDevEnvironment) is never reached because of the early return.

    Workaround that works for us — a pre plugin that forces the SSR env to be Runnable, using createRunnableDevEnvironment resolved through the same (aliased) vite specifier:

    import { createRunnableDevEnvironment } from "vite";
    import type { Plugin } from "vite";
    
    function forceRunnableSsrEnvironment(): Plugin {
      return {
        name: "force-runnable-ssr-env",
        enforce: "pre",
        config() {
          return {
            environments: {
              ssr: { dev: { createEnvironment: (name, config) => createRunnableDevEnvironment(name, config) } },
            },
          };
        },
      };
    }

    With this, the middleware installs and SSR HTML is served (HTTP 200) under vp dev.

    Two possible upstream fixes, fwiw:

    1. Have start-plugin-core set environments.ssr.dev.createEnvironment = createRunnableDevEnvironment itself when configuring the SSR env (it currently sets consumer: 'server' but doesn't pin the dev environment factory), so it doesn't depend on the host's default being Runnable.
    2. Expose installDevServerMiddleware to the vite plugin config (today only the rsbuild path reads it per schema.js), so users can opt in without patching the package.

    Happy to provide a minimal npm-workspaces reproducer if useful.

  8. qeeqez commented on Jul 11, 2026

    @qeeqez

    similar issue for the Vite 8 release - #7614

  9. schiller-manuel commented on Sep 7, 2026

    @schiller-manuel
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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