From a7e322202344779af9acc5514e0fdfbf92805179 Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Tue, 25 Feb 2025 16:51:27 -0300 Subject: [PATCH] fix edge case on ticker --- consensus/bor/heimdall/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/consensus/bor/heimdall/client.go b/consensus/bor/heimdall/client.go index 0e19aac356..ed7ca31b6d 100644 --- a/consensus/bor/heimdall/client.go +++ b/consensus/bor/heimdall/client.go @@ -33,6 +33,7 @@ var ( const ( heimdallAPIBodyLimit = 128 * 1024 * 1024 // 128 MB stateFetchLimit = 50 + retryCall = 5 * time.Second ) type StateSyncEventsResponse struct { @@ -292,7 +293,13 @@ func FetchWithRetry[T any](ctx context.Context, client http.Client, url *url.URL log.Warn("an error while trying fetching from Heimdall", "path", url.Path, "attempt", attempt, "error", err) // create a new ticker for retrying the request - ticker := time.NewTicker(client.Timeout) + var ticker *time.Ticker + if client.Timeout != 0 { + ticker = time.NewTicker(client.Timeout) + } else { + // only reach here when HeimdallClient is HeimdallGRPCClient or HeimdallAppClient + ticker = time.NewTicker(retryCall) + } defer ticker.Stop() const logEach = 5