From 770023398bc1c3af9594769b9b09bb9f46407f1b Mon Sep 17 00:00:00 2001 From: Franco Barpp Gomes Date: Wed, 1 May 2024 07:00:16 -0300 Subject: [PATCH] Check shutdown error on resend (#135) * fix: Check shutdown error on resend * feat: Handle general shutdown errors while resending --- operator/rpc_client.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/operator/rpc_client.go b/operator/rpc_client.go index 2bef5337..0ac1d470 100644 --- a/operator/rpc_client.go +++ b/operator/rpc_client.go @@ -183,9 +183,21 @@ func (c *AggregatorRpcClient) tryResendFromDeque() { if err != nil { c.logger.Error("Couldn't resend message", "err", err) - if i == 0 { - c.logger.Error("Couldn't resend first message, most likely a connection error") - return + if err == rpc.ErrShutdown { + c.logger.Error("Couldn't resend message due to shutdown") + + if errorPos == 0 { + c.unsentMessages = c.unsentMessages[i:] + return + } + + for j := i; j < len(c.unsentMessages); j++ { + message := c.unsentMessages[j] + c.unsentMessages[errorPos] = message + errorPos++ + } + + break } c.unsentMessages[errorPos] = message