diff --git a/CHANGELOG.md b/CHANGELOG.md index d2e0164202..0e316f039b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Test: Upgrade nim-waku node to v0.4. - Waku Light Push upgraded to `2.0.0-beta1`. +- Examples (web chat): Catch error if chat message decoding fails. ## [0.6.0] - 2021-06-09 diff --git a/examples/web-chat/src/Message.ts b/examples/web-chat/src/Message.ts index cb49a14440..2ec9884caf 100644 --- a/examples/web-chat/src/Message.ts +++ b/examples/web-chat/src/Message.ts @@ -12,9 +12,17 @@ export class Message { static fromWakuMessage(wakuMsg: WakuMessage): Message | undefined { if (wakuMsg.payload) { - const chatMsg = ChatMessage.decode(wakuMsg.payload); - if (chatMsg) { - return new Message(chatMsg, wakuMsg.timestamp); + try { + const chatMsg = ChatMessage.decode(wakuMsg.payload); + if (chatMsg) { + return new Message(chatMsg, wakuMsg.timestamp); + } + } catch (e) { + console.error( + 'Failed to decode chat message', + wakuMsg.payloadAsUtf8, + e + ); } } return;