Skip to content

Commit

Permalink
Catch and recover from stats crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeguyy authored and robschleusner committed Oct 25, 2023
1 parent 4adbe9e commit f28e60a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions quaistats/quaistats.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ func (s *Service) Stop() error {
// loop keeps trying to connect to the netstats server, reporting chain events
// until termination.
func (s *Service) loop(chainHeadCh chan core.ChainHeadEvent, chainSideCh chan core.ChainSideEvent) {
defer func() {
if r := recover(); r != nil {
fmt.Println("Stats process crashed with error:", r)
go s.loop(chainHeadCh, chainSideCh)
}
}()

// Start a goroutine that exhausts the subscriptions to avoid events piling up
var (
quitCh = make(chan struct{})
Expand Down

0 comments on commit f28e60a

Please sign in to comment.