oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.46k stars 2.71k forks source link

createWebSocketStream in `ws` package not implemented #4568

Open sapter opened 1 year ago

sapter commented 1 year ago

What version of Bun is running?

0.8.1+16b4bf341acc0f4804f0b6bdf5298c180cd00366

What platform is your computer?

Darwin 22.5.0 arm64 arm

What steps can reproduce the bug?

The createWebSocketStream method from the ws package breaks. Users get a Not supported yet in Bun error when trying to use it.

import WebSocket, { createWebSocketStream } from "ws";

{...}

const s = new WebSocket(this.env.SOCKET_URL);
// The line below breaks in Bun :=(
const duplex: Duplex = createWebSocketStream(s, { decodeStrings: false }); 

What is the expected behavior?

The createWebSocketStream works

What do you see instead?

Not supported yet in Bun error

Additional information

Looks like Bun overwrites the ws package. But not all methods in that package have been implemented leaving many users unable to use the package.

sapter commented 1 year ago

Related to #3613

RobertAron commented 1 year ago

I'm also really looking forward to using the ws support. Specifically my use case is utilizing mqtt.

https://github.com/mqttjs/MQTT.js

cyrus-za commented 12 months ago

Same here. Use case prisma pulse https://www.prisma.io/docs/data-platform/pulse/what-is-pulse

sorenbs commented 7 months ago

We would like for Prisma Pulse to support Bun. Is there a way we can help get this prioritised?

RobertAron commented 6 months ago

I think this is resolved with version 1.1 :D

Screenshot 2024-04-01 at 12 20 45 PM

RobertAron commented 5 months ago

Just got the opportunity to try this out today and unfortunately it doesn't seem like mqtt.js is working.

812 | class Receiver {
813 |   constructor() {
814 |     throw new Error("Not supported yet in Bun");
815 |   }
816 | }
817 | var createWebSocketStream = (ws) => {

error: Not supported yet in Bun
      at ws:817:57
      at streamBuilder (/Users/robert/Desktop/dev/event-rewrite/node_modules/mqtt/build/lib/connect/ws.js:113:29)
      at wrapper (/Users/robert/Desktop/dev/event-rewrite/node_modules/mqtt/build/lib/connect/index.js:130:16)
      at connect (/Users/robert/Desktop/dev/event-rewrite/node_modules/mqtt/build/lib/client.js:215:23)
      at new MqttClient (/Users/robert/Desktop/dev/event-rewrite/node_modules/mqtt/build/lib/client.js:191:13)
      at connect (/Users/robert/Desktop/dev/event-rewrite/node_modules/mqtt/build/lib/connect/index.js:132:20)
      at makeMqttClient (/Users/robert/Desktop/dev/event-rewrite/apps/common/dist/connection-utils.js:11:24)
      at /Users/robert/Desktop/dev/event-rewrite/apps/batcher/src/utils/connections.ts:5:25