From 85e4f5dbf21c6c97e757fe6d8d34d2b57de82b56 Mon Sep 17 00:00:00 2001 From: Ran Mishael <106548467+ranlavanet@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:25:13 +0200 Subject: [PATCH] fix: PRT - fix issue where in some cases sending regular messages would reach the subscription flow and spam the logger with api mismatches (#1717) --- protocol/chainlib/consumer_websocket_manager.go | 8 ++++---- protocol/metrics/rpcconsumerlogs.go | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/protocol/chainlib/consumer_websocket_manager.go b/protocol/chainlib/consumer_websocket_manager.go index e6edb7aaa6..3b126839ca 100644 --- a/protocol/chainlib/consumer_websocket_manager.go +++ b/protocol/chainlib/consumer_websocket_manager.go @@ -223,7 +223,6 @@ func (cwm *ConsumerWebsocketManager) ListenToMessages() { if err != nil { continue } - websocketConnWriteChan <- webSocketMsgWithType{messageType: messageType, msg: msgData} } } @@ -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 } } diff --git a/protocol/metrics/rpcconsumerlogs.go b/protocol/metrics/rpcconsumerlogs.go index 606ce8f114..5171faa1bb 100644 --- a/protocol/metrics/rpcconsumerlogs.go +++ b/protocol/metrics/rpcconsumerlogs.go @@ -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 }