You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A time.Timer does not need to be drained to avoid leaks. (The Timer.C channel is buffered, and buffered channels can be GC'd even if there are values in the buffer.)
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Looking at the code for the rate limiter, in
WaitN
https://github.com/golang/time/blob/9d24e82272b4f38b78bc8cff74fa936d31ccd8ef/rate/rate.go#L252 the return value oft.Stop()
is not checked, if the timer expired between the context being cancelled and the defer being executed then this timer will be blocked sending ont.C
and I believe will be leaked.What did you expect to see?
Timer should be drained after calling
Stop()
, this should be done in thecase <-ctx.Done()
What did you see instead?
Result of
Stop()
not checked and the timer potentially leaked.The text was updated successfully, but these errors were encountered: