Skip to content

Commit 9a954c3

Browse files
committed
[release-v2.0] chain: Wait for errgroup before returning from sync
If syncing over JSON-RPC is being reattempted in a loop, as the main package does, not waiting for the errgroup that runs the wallet's mixing client may cause it to concurrently enter mixclient.Client.Run again before it has returned. This eventually results in a panic due to closing the already-closed warming chan. Backport of 8b9a63d.
1 parent 9df1e49 commit 9a954c3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

chain/sync.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,14 @@ func (s *Syncer) Run(ctx context.Context) (err error) {
632632
return err
633633
}
634634

635+
ctx, cancel := context.WithCancel(ctx)
635636
g, ctx := errgroup.WithContext(ctx)
637+
defer func() {
638+
cancel()
639+
if e := g.Wait(); err == nil {
640+
err = e
641+
}
642+
}()
636643
g.Go(func() error {
637644
// Run wallet background goroutines (currently, this just runs
638645
// mixclient).

0 commit comments

Comments
 (0)