fix: goroutine leak

This commit is contained in:
0xff-dev
2023-10-08 15:45:20 +08:00
parent 779f153071
commit f7bc0aced8
4 changed files with 22 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ import (
// TimedCall runs fn, failing if it doesn't complete in the given duration.
// The description is used in the timeout error message.
func TimedCall(description string, d time.Duration, fn func() error) error {
done := make(chan error)
done := make(chan error, 1)
timer := time.NewTimer(d)
defer timer.Stop()
go func() { done <- fn() }()