fix: gracefully handle unavailable view-once messages and improve log error (#2070)
This commit is contained in:
committed by
GitHub
parent
abf5af0e72
commit
e5f820d119
@@ -1143,6 +1143,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const encNode = getBinaryNodeChild(node, 'enc')
|
||||
const unavailableNode = getBinaryNodeChild(node, 'unavailable')
|
||||
|
||||
// TODO: temporary fix for crashes and issues resulting of failed msmsg decryption
|
||||
if (encNode && encNode.attrs.type === 'msmsg') {
|
||||
@@ -1151,6 +1152,15 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
return
|
||||
}
|
||||
|
||||
if (unavailableNode) {
|
||||
logger.warn(
|
||||
{ id: node.attrs.id, from: node.attrs.from, type: unavailableNode.attrs?.type },
|
||||
'received unavailable message, sending positive ack'
|
||||
)
|
||||
await sendMessageAck(node)
|
||||
return
|
||||
}
|
||||
|
||||
const {
|
||||
fullMessage: msg,
|
||||
category,
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
type BinaryNode,
|
||||
binaryNodeToString,
|
||||
encodeBinaryNode,
|
||||
getAllBinaryNodeChildren,
|
||||
getBinaryNodeChild,
|
||||
getBinaryNodeChildren,
|
||||
isLidUser,
|
||||
@@ -908,11 +909,12 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
})
|
||||
|
||||
ws.on('CB:stream:error', (node: BinaryNode) => {
|
||||
logger.error({ node }, 'stream errored out')
|
||||
const [reasonNode] = getAllBinaryNodeChildren(node)
|
||||
logger.error({ reasonNode, fullErrorNode: node }, 'stream errored out')
|
||||
|
||||
const { reason, statusCode } = getErrorCodeFromStreamError(node)
|
||||
|
||||
end(new Boom(`Stream Errored (${reason})`, { statusCode, data: node }))
|
||||
end(new Boom(`Stream Errored (${reason})`, { statusCode, data: reasonNode || node }))
|
||||
})
|
||||
// stream fail, possible logout
|
||||
ws.on('CB:failure', (node: BinaryNode) => {
|
||||
|
||||
Reference in New Issue
Block a user