Skip to content

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

Closed as duplicate

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

Activity

  1. added
    pending triage
    on Mar 24, 2026
  2. HamishWHC commented on Apr 14, 2026

    @HamishWHC

    Same issue here (except I get an explicit [crossws] Using Node.js adapter in an incompatible environment.), massive pain in the ass. Have tried patching the import statement but vite simply fails with ResolveMessage {}.

  3. HamishWHC commented on Apr 14, 2026

    @HamishWHC

    Ok I patched the dependency correctly now, and am getting the same "Upstream server did not upgrade the connection" error.

  4. added
    bug
    and removed
    pending triage
    on Sep 2, 2026
  5. pi0x commented on Sep 7, 2026

    @pi0x
    Contributor

    Duplicate of #3939, tracking there. Same cause: the dev worker entry (src/runtime/internal/vite/dev-entry.mjs) always imports the Node build of crossws, whatever runtime Vite is actually running on. Still broken on main.

    Posted by an AI triage agent on behalf of a maintainer.

  6. added
    vite
    on Sep 7, 2026
  7. added theissue type on Nov 10, 2026
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

    bugpreset:bunvite

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions