From e96e1f0569ccb62acfacc5686453fda9884db0be Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Mon, 6 Jul 2020 16:55:55 -0700 Subject: [PATCH] Add a placeholder constant for ignoring cancelled subscription errors from libp2p pubsub. (#6496) * Add a placeholder constant for ignoring cancelled subscription errors from libp2p pubsub. This change temporarily resolves https://github.com/prysmaticlabs/prysm/issues/6449. This change should be revisited after https://github.com/libp2p/go-libp2p-pubsub/pull/356 merges and the prysm libp2p pubsub dependency is updated. * Merge branch 'master' into issue-6449 * Merge branch 'master' into issue-6449 * Merge branch 'master' into issue-6449 --- beacon-chain/sync/subscriber.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/beacon-chain/sync/subscriber.go b/beacon-chain/sync/subscriber.go index a83253b6f7..ef4bbcf659 100644 --- a/beacon-chain/sync/subscriber.go +++ b/beacon-chain/sync/subscriber.go @@ -2,6 +2,7 @@ package sync import ( "context" + "errors" "fmt" "reflect" "runtime/debug" @@ -25,6 +26,11 @@ import ( const pubsubMessageTimeout = 30 * time.Second +var ( + // TODO(6449): Replace this with pubsub.ErrSubscriptionCancelled. + errSubscriptionCancelled = errors.New("subscription cancelled by calling sub.Cancel()") +) + // subHandler represents handler for a given subscription. type subHandler func(context.Context, proto.Message) error @@ -147,7 +153,9 @@ func (s *Service) subscribeWithBase(base proto.Message, topic string, validator msg, err := sub.Next(s.ctx) if err != nil { // This should only happen when the context is cancelled or subscription is cancelled. - log.WithError(err).Warn("Subscription next failed") + if err != errSubscriptionCancelled { // Only log a warning on unexpected errors. + log.WithError(err).Warn("Subscription next failed") + } return }