Skip to content

Commit

Permalink
fix: PRT - fix issue where in some cases sending regular messages wou…
Browse files Browse the repository at this point in the history
…ld reach the subscription flow and spam the logger with api mismatches (#1717)
  • Loading branch information
ranlavanet authored Sep 26, 2024
1 parent 5e3e277 commit 85e4f5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions protocol/chainlib/consumer_websocket_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ func (cwm *ConsumerWebsocketManager) ListenToMessages() {
if err != nil {
continue
}

websocketConnWriteChan <- webSocketMsgWithType{messageType: messageType, msg: msgData}
}
}
Expand All @@ -241,17 +240,18 @@ func (cwm *ConsumerWebsocketManager) ListenToMessages() {
formatterMsg := logger.AnalyzeWebSocketErrorAndGetFormattedMessage(websocketConn.LocalAddr().String(), utils.LavaFormatError("could not send parsed relay", err), msgSeed, msg, cwm.apiInterface, time.Since(startTime))
if formatterMsg != nil {
websocketConnWriteChan <- webSocketMsgWithType{messageType: messageType, msg: formatterMsg}
continue
}
continue
}

relayResultReply := relayResult.GetReply()
if relayResultReply != nil {
// No need to verify signature since this is already happening inside the SendParsedRelay flow
websocketConnWriteChan <- webSocketMsgWithType{messageType: messageType, msg: relayResult.GetReply().Data}
continue
} else {
utils.LavaFormatError("Relay result is nil over websocket normal request flow, should not happen", err, utils.LogAttr("messageType", messageType))
}
utils.LavaFormatError("Relay result is nil over websocket normal request flow, should not happen", err, utils.LogAttr("messageType", messageType))
continue
}
}

Expand Down
7 changes: 4 additions & 3 deletions protocol/metrics/rpcconsumerlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,14 @@ func (rpccl *RPCConsumerLogs) AnalyzeWebSocketErrorAndGetFormattedMessage(webSoc
}
rpccl.LogRequestAndResponse(rpcType+" ws msg", true, "ws", webSocketAddr, string(msg), "", msgSeed, timeTaken, err)

jsonResponse, _ := json.Marshal(fiber.Map{
jsonResponse, err := json.Marshal(fiber.Map{
"Error_Received": rpccl.GetUniqueGuidResponseForError(err, msgSeed),
})

if err != nil {
utils.LavaFormatError("AnalyzeWebSocketErrorAndGetFormattedMessage unexpected behavior, failed marshalling json response", err, utils.LogAttr("seed", msgSeed))
}
return jsonResponse
}

return nil
}

Expand Down

0 comments on commit 85e4f5d

Please sign in to comment.