fix: harness tests random panic (#10933)
* fix: harness tests random panic Connecting nodes in parallel can cause TLS handshake failures. For each node, connect to the other nodes serially. It is not necessary to connect in parallel as it does not save any significant time. Closes #10932
Andrew Gillis committed
Aug 22, 2025 at 13:57 UTC
ae068a806181dc09d4d679ba8d3c6e5f3547afac
1 file changed
+8
-18
test/cli/harness/nodes.go
+8
-18
@@ -5,7 +5,6 @@ import (
5
6
. "github.com/ipfs/kubo/test/cli/testutils"
7
"github.com/multiformats/go-multiaddr"
8
- "golang.org/x/sync/errgroup"
8
)
9
10
// Nodes is a collection of Kubo nodes along with operations on groups of nodes.
@@ -17,37 +16,28 @@ func (n Nodes) Init(args ...string) Nodes {
16
}
17
18
func (n Nodes) ForEachPar(f func(*Node)) {
20
- group := &errgroup.Group{}
19
+ var wg sync.WaitGroup
20
for _, node := range n {
21
+ wg.Add(1)
22
node := node
23
- group.Go(func() error {
23
+ go func() {
24
+ defer wg.Done()
25
f(node)
25
- return nil
26
- })
27
- }
28
- err := group.Wait()
29
- if err != nil {
30
- panic(err)
26
+ }()
27
}
28
+ wg.Wait()
29
}
30
31
func (n Nodes) Connect() Nodes {
35
- wg := sync.WaitGroup{}
32
for i, node := range n {
33
for j, otherNode := range n {
34
if i == j {
35
continue
36
}
41
- node := node
42
- otherNode := otherNode
43
- wg.Add(1)
44
- go func() {
45
- defer wg.Done()
46
- node.Connect(otherNode)
47
- }()
37
+ // Do not connect in parallel, because that can cause TLS handshake problems on some platforms.
38
+ node.Connect(otherNode)
39
}
40
}
50
- wg.Wait()
41
for _, node := range n {
42
firstPeer := node.Peers()[0]
43
if _, err := firstPeer.ValueForProtocol(multiaddr.P_P2P); err != nil {