Skip to content

Commit

Permalink
Add 5 second max to redial attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav committed Jan 7, 2025
1 parent 480c5de commit 6e21897
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/services/relay/evm/mercury/wsrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,15 @@ func (w *client) resetTransport() {
ctx, cancel := w.chStop.NewCtx()
defer cancel()
b := utils.NewRedialBackoff()
var cnt int
for {
// Will block until successful dial, or context is canceled (i.e. on close)
err := w.dial(ctx, wsrpc.WithBlock())
cnt++
w.logger.Warnw("ResetTransport resetting transport", "attempt", cnt)
// Will block until successful dial, or context is canceled
// If it takes longer than 5 seconds to try to dial, abort and retry to avoid getting stuck
loopCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
err := w.dial(loopCtx, wsrpc.WithBlock())
cancel()
if err == nil {
break
}
Expand Down

0 comments on commit 6e21897

Please sign in to comment.