Skip to content

Commit

Permalink
fix: return error in relay publish if exceeding max-msg-size (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyaprem authored Dec 1, 2023
1 parent ac1a699 commit 6bd85a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion waku/metrics/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions waku/v2/protocol/relay/waku_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6bd85a1

Please sign in to comment.