Skip to content

Commit

Permalink
fix: make sure message data is of type uint8array
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 14, 2024
1 parent 41a979b commit 8197759
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 8197759

Please sign in to comment.