From f69a1f66728395568a227e4c8f92db0f1f4aa118 Mon Sep 17 00:00:00 2001 From: Engin Date: Wed, 2 Oct 2024 22:44:03 +0300 Subject: [PATCH] Make the header if it is empty --- jetstream/pull.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jetstream/pull.go b/jetstream/pull.go index 386968108..a2d6b4478 100644 --- a/jetstream/pull.go +++ b/jetstream/pull.go @@ -205,6 +205,9 @@ func (p *pullConsumer) Consume(handler MessageHandler, opts ...PullConsumeOpt) ( p.Unlock() internalHandler := func(msg *nats.Msg) { + if msg.Header == nil { + msg.Header = make(nats.Header) + } if sub.hbMonitor != nil { sub.hbMonitor.Stop() } @@ -781,6 +784,9 @@ func (p *pullConsumer) fetch(req *pullRequest) (MessageBatch, error) { select { case msg := <-msgs: p.Lock() + if msg.Header == nil { + msg.Header = make(nats.Header) + } if hbTimer != nil { hbTimer.Reset(2 * req.Heartbeat) }