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 }