Skip to content

Commit 9d5df80

Browse files
committed
Fix error thrown with utf8 decoding
1 parent 75d420b commit 9d5df80

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

examples/web-chat/src/Message.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ export class Message {
1919
return new Message(chatMsg, wakuMsg.timestamp);
2020
}
2121
} catch (e) {
22-
console.error(
23-
"Failed to decode chat message",
24-
wakuMsg.payloadAsUtf8,
25-
e
26-
);
22+
console.error("Failed to decode chat message", e);
2723
}
2824
}
2925
return;

src/lib/waku_message/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ export class WakuMessage {
256256
return "";
257257
}
258258

259-
return bytesToUtf8(this.proto.payload);
259+
try {
260+
return bytesToUtf8(this.proto.payload);
261+
} catch (e) {
262+
return "";
263+
}
260264
}
261265

262266
get payload(): Uint8Array | undefined {

0 commit comments

Comments
 (0)