Wrap decoding in try...catch (#279)
This commit is contained in:
parent
9010b1d585
commit
fb78bc5dc8
|
@ -41,7 +41,9 @@ export function handleWakuMessage(
|
||||||
if (decodedProtocol) {
|
if (decodedProtocol) {
|
||||||
messageToDecode = decodedProtocol.publicMessage
|
messageToDecode = decodedProtocol.publicMessage
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
}
|
||||||
|
|
||||||
const decodedMetadata = ApplicationMetadataMessage.decode(messageToDecode)
|
const decodedMetadata = ApplicationMetadataMessage.decode(messageToDecode)
|
||||||
if (!decodedMetadata.payload) {
|
if (!decodedMetadata.payload) {
|
||||||
|
@ -67,6 +69,7 @@ export function handleWakuMessage(
|
||||||
let success = false
|
let success = false
|
||||||
|
|
||||||
// decode, map and handle (events)
|
// decode, map and handle (events)
|
||||||
|
try {
|
||||||
switch (decodedMetadata.type) {
|
switch (decodedMetadata.type) {
|
||||||
case ApplicationMetadataMessage.Type.TYPE_COMMUNITY_DESCRIPTION: {
|
case ApplicationMetadataMessage.Type.TYPE_COMMUNITY_DESCRIPTION: {
|
||||||
// decode
|
// decode
|
||||||
|
@ -168,6 +171,10 @@ export function handleWakuMessage(
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
// protons-runtime throws when trying to decode invalid protocol buffers
|
||||||
|
success = true
|
||||||
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
client.wakuMessages.add(messageId)
|
client.wakuMessages.add(messageId)
|
||||||
|
|
Loading…
Reference in New Issue