You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importWebSocketfrom"ws";constwss=newWebSocket.Server({port: 3000});wss.on("connection",ws=>{console.log("connection");ws.send("Hello world");ws.close();});wss.on("listening",()=>{console.log("listening");});console.log("Started WebSocket server (?)");
When this file is run with Node it requires that the ws package is installed, and when it is run it outputs
Started WebSocket server (?)
listening
And attempts to connect to it succeed.
Running the same file with Bun works even without the ws package installed, and produces the output
Started WebSocket server (?)
And it does not accept any connections.
What is the expected behavior?
I would expect that if I install the ws package then Bun should use the ws package, and if it is going to override that then the replacement should at least be compatible and functional.
What do you see instead?
No response
Additional information
Yes I know that Bun.serve can do websockets, but I'm trying to use a different package that itself uses ws under the hood, and I don't want to have to rewrite that whole package just to make it work with Bun's idiosyncrasies.
The text was updated successfully, but these errors were encountered:
I see there is a PR up to fix this, but is there any way I can work around this in the meantime? Is there any way for me to tell Bun to just load the ws package from node_modules instead of using the built-in version?
@Jarred-Sumner@cirospaciari I just updated from 0.6.2 to v0.6.3 and it's still broken. Running the above code in Node produces a stable WebSocket server that I can connect to. Running the same code in Bun 0.6.3 logs "Started WebSocket server (?)" and immediately exits. Even if I introduce an artificial delay to keep it from exiting (setTimeout(() => {}, 60_000)) it still never logs "listening" or "connection", and attempts to connect with a client fail with WebSocket connection to 'ws://<address>:<port>/' failed: There was a bad response from the server.
Is there really no way I can just use the ws package from node_modules? Why is Bun overriding this 3rd-party package anyway?
Due to the missing exports for ping/pong in Bun.serve i tried to use ws as fallback until Bun.serve is fixed.
I am using Bun 0.6.13 on Darwin 22.5.0 x86_64 i386 and this problem still persists.
What version of Bun is running?
0.6.2
What platform is your computer?
Darwin 22.4.0 x86_64 i386
What steps can reproduce the bug?
Here is a minimal example file:
When this file is run with Node it requires that the
ws
package is installed, and when it is run it outputsAnd attempts to connect to it succeed.
Running the same file with Bun works even without the
ws
package installed, and produces the outputAnd it does not accept any connections.
What is the expected behavior?
I would expect that if I install the
ws
package then Bun should use thews
package, and if it is going to override that then the replacement should at least be compatible and functional.What do you see instead?
No response
Additional information
Yes I know that
Bun.serve
can do websockets, but I'm trying to use a different package that itself usesws
under the hood, and I don't want to have to rewrite that whole package just to make it work with Bun's idiosyncrasies.The text was updated successfully, but these errors were encountered: