stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.7k stars 139 forks source link

WebSocket client + arraybuffer binaryType issue #1182

Open endel opened 9 months ago

endel commented 9 months ago

Description of Bug

The WebSocket client doesn't seem to be receiving the payload correctly when using .binaryType = "arraybuffer".

https://stackblitz.com/edit/stackblitz-starters-uuauht?file=public%2Findex.html

Steps to Reproduce

  1. Start the http/ws server
  2. Open the "/" URL in the browser
  3. See the console logs on the browser's Developer Tools
  4. You will notice that received bytes differ depending on the binaryType used ("blob" receives correctly, whereas "arraybuffer" seems to be receiving additional bytes)
Received bytes (arraybuffer): [130, 1, 10]
Received bytes (blob): [10]

Expected Behavior

Both WebSocket client connections should be receiving the exact data sent by the server ([10])

Received bytes (arraybuffer): [10]
Received bytes (blob): [10]

Screenshots/Screencast

Screenshot 2023-09-15 at 16 13 13

Nemikolh commented 9 months ago

Hi @endel ! Thank you so much for the minimal reproduction link! :star2: Super cool :smiley:

We'll investigate, our support for arraybuffer might be buggy.

I'll keep you posted!

terry-fei commented 5 months ago

https://github.com/websockets/ws/issues/1175 It might be helpful

remocons commented 6 days ago

It has been 10 months. Please resolve this issue quickly.