diff --git a/waku/v2/rest/relay.go b/waku/v2/rest/relay.go index b5ffc8a7..5f6de6d6 100644 --- a/waku/v2/rest/relay.go +++ b/waku/v2/rest/relay.go @@ -128,8 +128,9 @@ func (d *RelayService) postV1Subscriptions(w http.ResponseWriter, r *http.Reques d.log.Error("subscribing to topic", zap.String("topic", strings.Replace(topicToSubscribe, "\n", "", -1)), zap.Error(err)) } else { d.node.Broadcaster().Unregister(&topicToSubscribe, sub.C) - + d.messagesMutex.Lock() d.messages[topic] = []*pb.WakuMessage{} + d.messagesMutex.Unlock() } } diff --git a/waku/v2/rpc/relay.go b/waku/v2/rpc/relay.go index 6de142e3..6bb3b982 100644 --- a/waku/v2/rpc/relay.go +++ b/waku/v2/rpc/relay.go @@ -116,7 +116,9 @@ func (r *RelayService) PostV1Subscription(req *http.Request, args *TopicsArgs, r r.log.Error("subscribing to topic", zap.String("topic", topic), zap.Error(err)) return err } + r.messagesMutex.Lock() r.messages[topic] = make([]*pb.WakuMessage, 0) + r.messagesMutex.Unlock() } *reply = true