nitrojs / nitrojs/nitro

Websocket does not work in vite dev mode with bun runtime

Open
#3,939 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug bun v3 vite plugin
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

Nitro 3.0.1-alpha.1
Bun 1.3.5

Reproduction

vite.config.ts

import { defineConfig } from "vite";
import { nitro } from "nitro/vite";

export default defineConfig({
  plugins: [nitro()],
  nitro: {
    preset: "bun",
    features: { websocket: true }
  }
});

package.json

{
  "type": "module",
  "scripts": {
    "dev": "bun --bun vite dev"
  },
  "devDependencies": {
    "nitro": "3.0.1-alpha.1",
    "vite": "npm:rolldown-vite"
  }
}
Describe the bug
36 | const nodeAdapter = (options = {}) => {
37 |     throw new Error(
               ^
error: [crossws] Using Node.js adapter in an incompatible environment.
      at nodeAdapter
Additional context

No response

Logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the vite.config.ts reproduction and run bun --bun vite dev using the Bun preset and websocket feature. Trace why the dev server selects the crossws Node.js adapter in this environment. Done means websocket support works in Vite dev mode under Bun without the incompatible-environment error.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, typescript, vite
Domain
backend, build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.