From 819775984fcb02fd62023fb6aa8b6776f713d8a3 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 14 Aug 2024 20:09:01 +0200 Subject: [PATCH] fix: make sure message data is of type uint8array --- src/server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index 7c43baa..2d2e2f3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -59,7 +59,9 @@ export class YCrossws { const doc = this.getDoc(peer); try { const encoder = encoding.createEncoder(); - const decoder = decoding.createDecoder(message.rawData); + const _data = message.rawData; + const data = _data instanceof Uint8Array ? _data : new Uint8Array(_data); + const decoder = decoding.createDecoder(data); const messageType = decoding.readVarUint(decoder); switch (messageType) { case messageSync: {