Skip to content

Commit d643cb6

Browse files
committed
fix: correct logic for reconnect loop
1 parent 721f874 commit d643cb6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

websocket.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,15 +630,17 @@ func (c *wsConn) tryReconnect(ctx context.Context) bool {
630630
var conn *websocket.Conn
631631
for conn == nil {
632632
time.Sleep(c.reconnectBackoff.next(attempts))
633+
if ctx.Err() != nil {
634+
return
635+
}
633636
var err error
634637
if conn, err = c.connFactory(); err != nil {
635638
log.Debugw("websocket connection retry failed", "error", err)
636639
}
637640
select {
638641
case <-ctx.Done():
639-
break
642+
return
640643
default:
641-
continue
642644
}
643645
attempts++
644646
}

0 commit comments

Comments
 (0)