-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
Describe the bug
In vite ssr, if I separate vite config logic to different files like vite.client.config.ts
and vite.server.config.ts
, and I get viteDevServer
instance by calling createServer
method use these configurations.
On the server side, I use ssrLoadModule
in the viteDevServer instance, like
const viteServer = await createServer(serverConfig)
await (viteServer as ViteDevServer).ssrLoadModule(viteServerEntry)
On the client side, I use a ViteDevServer instance with middleware mode, like
const viteServer: ViteDevServer = await createServer(clientConfig)
proxyMiddlewaresArr.push(viteServer.middlewares)
It's a common practice in server-side render projects. But in rolldown-vite
, the websocket server will call the listen function twice because createServer
is called twice. In my opinion, there is no need to create a Websocket server when I only use ViteDevServer
for ssrLoadModule
.
I can confirm the logic is expected in vite@^2.0.0
because I am upgrading [email protected] to rolldown-vite in my server-side render framework.
Reproduction
Steps to reproduce
$ git clone [email protected]:zhangyuang/vite-ssr-external-bug.git
$ git checkout bug/ssrdevserver
$ yarn && npm run dev
System Info
System:
OS: macOS 15.5
CPU: (14) arm64 Apple M4 Pro
Memory: 1012.33 MB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.4.1 - ~/Library/pnpm/node
Yarn: 1.22.22 - ~/Library/pnpm/yarn
npm: 10.8.2 - ~/Library/pnpm/npm
pnpm: 10.13.1 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 138.0.7204.169
Firefox Nightly: 140.0a1
Safari: 18.5
npmPackages:
vite: ^7.0.0 => 7.0.6
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.