Skip to content

Websockets feature does not work with vite running in through bun #4146

@TheComputerM

Description

@TheComputerM

Environment

Nitro: 3.0.260311-beta
Bun: v1.3.11
Node: v25.8.1

Reproduction

Simple vite + nitro project

import { nitro } from "nitro/vite";

// vite plugins
		nitro({ preset: "bun", features: { websocket: true } }),

Then run

bunx --bun vite dev --port 3000

https://stackblitz.com/edit/nitrojs-nitro-dzyb6ovc?file=package.json

Describe the bug

https://github.com/nitrojs/nitro/blob/main/src/runtime/internal/vite/dev-entry.mjs will always load the node version of crossws, even if vite is running through bun mode.

Additional context

No response

Logs

830 |           )
831 |         );
832 |         res.pipe(sock);
833 |         if (!settled) {
834 |           settled = true;
835 |           reject(new Error("Upstream server did not upgrade the connection"));
                           ^
error: Upstream server did not upgrade the connection
      at <anonymous> (/Users/thecomputerm/Workspace/cerebro/node_modules/httpxy/dist/index.mjs:835:22)
      at emit (node:events:95:22)
      at <anonymous> (node:_http_client:234:45)

Bun v1.3.11 (macOS arm64)
error: "vite" exited with code 1
error: script "dev" exited with code 1

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