Skip to content

Commit

Permalink
fix: negative or zero reconnect delay on higher reconnects (#78)
Browse files Browse the repository at this point in the history
The reconnect delay is set to a negative or zero value after 34th attempt. This fix sets it to the max delay value in that case.
  • Loading branch information
utekaravinash authored Apr 27, 2022
1 parent fdbe590 commit 7f5d702
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ticker/ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (t *Ticker) ServeWithContext(ctx context.Context) {
// If its a reconnect then wait exponentially based on reconnect attempt
if t.reconnectAttempt > 0 {
nextDelay := time.Duration(math.Pow(2, float64(t.reconnectAttempt))) * time.Second
if nextDelay > t.reconnectMaxDelay {
if nextDelay > t.reconnectMaxDelay || nextDelay <= 0 {
nextDelay = t.reconnectMaxDelay
}

Expand Down

0 comments on commit 7f5d702

Please sign in to comment.