Skip to content

Commit

Permalink
perform retry for 502 StatusBadGateway errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilevos committed Mar 28, 2024
1 parent acddbaa commit a0518a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions middlewares/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ func Retry(config *config.Config) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) (err error) {
if config.ConfigFile.TezosHostRetry == "" ||
c.Request().Method != http.MethodGet ||
strings.Contains(c.Request().URL.Path, "mempool") ||
strings.Contains(c.Request().URL.Path, "monitor") {
return next(c)
Expand All @@ -26,7 +25,8 @@ func Retry(config *config.Config) echo.MiddlewareFunc {
err = next(c)

status := c.Response().Status
if status == http.StatusNotFound || status == http.StatusForbidden {
if (c.Request().Method == http.MethodGet && (status == http.StatusNotFound || status == http.StatusForbidden)) ||
(c.Request().Method == http.MethodPost && status == http.StatusBadGateway) {
writer.Reset()
delayedResponse.Committed = false
delayedResponse.Size = 0
Expand Down

0 comments on commit a0518a6

Please sign in to comment.