From 6bd85a1dc99a9ebf350fd05099009dab6f7d3ebb Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Fri, 1 Dec 2023 06:53:28 +0530 Subject: [PATCH] fix: return error in relay publish if exceeding max-msg-size (#939) --- waku/metrics/http.go | 2 +- waku/v2/protocol/relay/waku_relay.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/waku/metrics/http.go b/waku/metrics/http.go index 6b734efc2..39342356c 100644 --- a/waku/metrics/http.go +++ b/waku/metrics/http.go @@ -43,7 +43,7 @@ func NewMetricsServer(address string, port int, log *zap.Logger) *Server { // Start executes the HTTP server in the background. func (p *Server) Start() { - p.log.Info("server stopped ", zap.Error(p.server.ListenAndServe())) + p.log.Info("server started ", zap.Error(p.server.ListenAndServe())) } // Stop shuts down the prometheus server diff --git a/waku/v2/protocol/relay/waku_relay.go b/waku/v2/protocol/relay/waku_relay.go index afc996edc..a1d279df3 100644 --- a/waku/v2/protocol/relay/waku_relay.go +++ b/waku/v2/protocol/relay/waku_relay.go @@ -289,6 +289,10 @@ func (w *WakuRelay) Publish(ctx context.Context, message *pb.WakuMessage, opts . return nil, err } + if len(out) > pubsub.DefaultMaxMessageSize { + return nil, errors.New("message size exceeds gossipsub max message size") + } + err = pubSubTopic.Publish(ctx, out) if err != nil { return nil, err