Skip to content

Commit

Permalink
[release-v2.0] chain: Wait for errgroup before returning from sync
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrick committed May 24, 2024
1 parent 9df1e49 commit 9a954c3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chain/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,14 @@ func (s *Syncer) Run(ctx context.Context) (err error) {
return err
}

ctx, cancel := context.WithCancel(ctx)
g, ctx := errgroup.WithContext(ctx)
defer func() {
cancel()
if e := g.Wait(); err == nil {
err = e
}
}()
g.Go(func() error {
// Run wallet background goroutines (currently, this just runs
// mixclient).
Expand Down

0 comments on commit 9a954c3

Please sign in to comment.