Proposer timer handling when the context is cancelled in random peer

This commit is contained in:
terence tsao
2025-10-26 12:25:47 -07:00
parent 4fb75d6d0b
commit fd65297676
2 changed files with 9 additions and 1 deletions

View File

@@ -1133,9 +1133,14 @@ func randomPeer(
"delay": waitPeriod,
}).Debug("Waiting for a peer with enough bandwidth for data column sidecars")
timer := time.NewTimer(waitPeriod)
select {
case <-time.After(waitPeriod):
case <-timer.C:
// Timer expired, retry the loop
case <-ctx.Done():
// Context cancelled - stop timer to prevent leak
timer.Stop()
return "", ctx.Err()
}
}

View File

@@ -0,0 +1,3 @@
### Changed
- Replace `time.After()` with `time.NewTimer()` and explicitly stop the timer when the context is cancelled