Open Anoesj opened 1 month ago
I think it has something to do with crossws
, as in the dev
and node
preset, Nitro is importing the one with Node adapter, not Bun.
I was commenting on https://github.com/unjs/nitro/discussions/1010 which is pretty similar to what I am running into. The repro there with the latest code (I had to update) and when running with bun did reproduce the error. With some changes to the dev-server/server.ts
code I got it to work.
Environment
Build Modules: -
Reproduction
https://github.com/Anoesj/nitro-bun-websocket-issue
Describe the bug
I'm trying to get WebSockets to work in a Nuxt application. I've turned on
nitro.experimental.websocket
innuxt.config.ts
and I'm using thebun
Nitro preset.During development (
bun --bun run dev
), the WebSocket'sonopen
event never fires, suggesting the connection can't be fully established, but doesn't "fail" either.After building the app and previewing it (
bun --bun run build && bun --bun run preview
), the WebSocket does work.When using the
node-server
Nitro preset instead, the WebSocket does not work in both development mode and after building and previewing the app.When switching to
node
by omitting the--bun
flag (so:bun run dev
/bun run build && bun run preview
), the WebSocket does work in both development mode and after building and preview the app, for both Nitro presetbun
andnode-server
.bun
bun
node-server
node-server
bun
bun
node-server
node-server
Additional context
Bun revision:
1.1.27+267afa293
Platform:Linux 6.8.0-40-generic x86_64 x86_64
.If this is a Nuxt issue, feel free to transfer the issue to the Nuxt repository.
Logs
No response