Skip to content

Commit

Permalink
fix: fetch span retry bug
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 authored and Victor Castell committed May 10, 2022
1 parent 2321e64 commit e4e5d4a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion consensus/bor/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
u.Path = rawPath
u.RawQuery = rawQuery

// attempt counter
attempt := 1

// request data once
res, err := h.internalFetch(u)
if err == nil && res != nil {
return res, nil
}
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path, "attempt", attempt)
attempt++

// create a new ticker for retrying the request
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
Expand All @@ -113,7 +124,8 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
if err == nil && res != nil {
return res, nil
}
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path)
log.Info("Retrying again in 5 seconds to fetch data from Heimdall", "path", u.Path, "attempt", attempt)
attempt++
}
}
}
Expand Down

0 comments on commit e4e5d4a

Please sign in to comment.