Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
$ go version
go version go1.12.9 linux/amd64
Looking at the code for the rate limiter, in WaitN https://github.com/golang/time/blob/9d24e82272b4f38b78bc8cff74fa936d31ccd8ef/rate/rate.go#L252 the return value of t.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 on t.C and I believe will be leaked.
Timer should be drained after calling Stop(), this should be done in the case <-ctx.Done()
Result of Stop() not checked and the timer potentially leaked.
The text was updated successfully, but these errors were encountered:
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.)
Sorry, something went wrong.
I don't think there is a bug here, but please reopen if you observe a leak empirically.
No branches or pull requests