bun
bun copied to clipboard
WebSocket client connection drops if an unknown opcode is received
What version of Bun is running?
0.4.0
What platform is your computer?
Microsoft Windows NT 10.0.22000.0 x64
What steps can reproduce the bug?
-
Using the global WebSocket implementation, create a Websocket connection
const ws = new WebSocket("wss://arealwebsocket.url"); -
Receive message that has an opcode that bun's global WebSocket implementation isn't familair with -- in my case I was receiving
MessageEvent { type: "message", data: "unknown opcode 15" } -
After receiving the previous message, the connection will drop. Wrapping the callback in a try-catch block doesnt prevent the connection from dropping.
What is the expected behavior?
The connection should persist -- or at the very least throw an exception.
What do you see instead?
No response
Additional information
At first I thought opcode 15 was PING or PONG until I read rfc6455 about reserved WebSocket opcodes. I assume this problem is due to opcodes outside the reserved range (if they're implemented or handled in Bun/the wrapper).
Its a protocol error, disconnecting is the correct behavior
I think the bug here is an issue in Bun's implementation of the websocket client and not that it disconnects
We need to test our WebSocket client using the Autobahn test suite to fix these bugs, including this one. For updates, please upvote and subscribe to this issue: https://github.com/oven-sh/bun/issues/6686