bun icon indicating copy to clipboard operation
bun copied to clipboard

WebSocket client connection drops if an unknown opcode is received

Open mia-z opened this issue 2 years ago • 2 comments

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?

  1. Using the global WebSocket implementation, create a Websocket connection const ws = new WebSocket("wss://arealwebsocket.url");

  2. 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" }

  3. 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).

mia-z avatar Jan 16 '23 19:01 mia-z

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

Jarred-Sumner avatar Jan 16 '23 20:01 Jarred-Sumner

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

Electroid avatar Oct 24 '23 13:10 Electroid