Skip to content

Commit afffe1c

Browse files
author
Aaron Schlesinger
committed
fix(pkg/sshd/common_test.go): increase verbosity of WaitGroup timeout errors
1 parent 197fc53 commit afffe1c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

pkg/sshd/common_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package sshd
22

33
import (
4-
"errors"
4+
"fmt"
55
"sync"
66
"time"
77
)
88

9-
var (
10-
errWGTimedOut = errors.New("waitgroup wait timed out")
11-
)
9+
type errWGTimedOut struct {
10+
to time.Duration
11+
}
12+
13+
func (e errWGTimedOut) Error() string {
14+
return fmt.Sprintf("WaitGroup wait timed out after %s", e.to)
15+
}
1216

1317
// waitWithTimeout waits for wg.Done() until timeout expires. returns errWGTimedOut if timeout expired before wg.Done() returned, otherwise returns nil. this func is naturally leaky if wg.Done() never returns
1418
func waitWithTimeout(wg *sync.WaitGroup, timeout time.Duration) error {
@@ -19,7 +23,7 @@ func waitWithTimeout(wg *sync.WaitGroup, timeout time.Duration) error {
1923
}()
2024
select {
2125
case <-time.After(timeout):
22-
return errWGTimedOut
26+
return errWGTimedOut{to: timeout}
2327
case <-ch:
2428
return nil
2529
}

0 commit comments

Comments
 (0)