From 80dd92ddb13da043f6f41d34941c81eaf2608e33 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 1 Sep 2023 06:39:25 -0400 Subject: [PATCH] fix: browser returns a Blob, so convert to a buffer if we have a blob --- src/transports/webSocket.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/transports/webSocket.ts b/src/transports/webSocket.ts index ceff822..96e0b3d 100644 --- a/src/transports/webSocket.ts +++ b/src/transports/webSocket.ts @@ -24,7 +24,13 @@ export class WebSocketPeer extends BasePeer implements Peer { this._socket.addEventListener( "message", async (event: MessageEvent) => { - await callback(event.data); + let data = event.data; + + if (data instanceof Blob) { + data = Buffer.from(await data.arrayBuffer()); + } + + await callback(data); }, );