mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
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
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user