From 2771226ed07a509607c5d6da7434c1287dc38d18 Mon Sep 17 00:00:00 2001 From: vgonkivs Date: Fri, 7 Feb 2025 14:16:07 +0200 Subject: [PATCH] close channel if subscription fails --- core/fetcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/fetcher.go b/core/fetcher.go index f772ac3a25..e47b913d96 100644 --- a/core/fetcher.go +++ b/core/fetcher.go @@ -169,17 +169,17 @@ func (f *BlockFetcher) SubscribeNewBlockEvent(ctx context.Context) (<-chan types } ctx, cancel := context.WithCancel(ctx) f.cancel = cancel + f.doneCh = make(chan struct{}) f.isListeningForBlocks.Store(true) subscription, err := f.client.SubscribeNewHeights(ctx, &coregrpc.SubscribeNewHeightsRequest{}) if err != nil { + close(f.doneCh) f.isListeningForBlocks.Store(false) return nil, err } log.Debug("created a subscription. Start listening for new blocks...") - - f.doneCh = make(chan struct{}) signedBlockCh := make(chan types.EventDataSignedBlock) go func() { defer close(f.doneCh)