diff --git a/waku/v2/peermanager/peer_manager.go b/waku/v2/peermanager/peer_manager.go index e12d3b24..2ac489a0 100644 --- a/waku/v2/peermanager/peer_manager.go +++ b/waku/v2/peermanager/peer_manager.go @@ -125,6 +125,10 @@ func inAndOutRelayPeers(relayPeers int) (int, int) { // checkAndUpdateTopicHealth finds health of specified topic and updates and notifies of the same. // Also returns the healthyPeerCount func (pm *PeerManager) checkAndUpdateTopicHealth(topic *NodeTopicDetails) int { + if topic == nil { + return 0 + } + healthyPeerCount := 0 for _, p := range pm.relay.PubSub().MeshPeers(topic.topic.String()) { diff --git a/waku/v2/protocol/relay/waku_relay.go b/waku/v2/protocol/relay/waku_relay.go index 05fc823d..936b37c5 100644 --- a/waku/v2/protocol/relay/waku_relay.go +++ b/waku/v2/protocol/relay/waku_relay.go @@ -493,6 +493,9 @@ func (w *WakuRelay) Unsubscribe(ctx context.Context, contentFilter waku_proto.Co // unsubscribeFromPubsubTopic unsubscribes subscription from underlying pubsub. // Note: caller has to acquire topicsMutex in order to avoid race conditions func (w *WakuRelay) unsubscribeFromPubsubTopic(topicData *pubsubTopicSubscriptionDetails) error { + if topicData.subscription == nil { + return nil + } pubSubTopic := topicData.subscription.Topic() w.log.Info("unsubscribing from pubsubTopic", zap.String("topic", pubSubTopic))