From 7b2ac25a31417246df57b3c0738c8ddd365209f7 Mon Sep 17 00:00:00 2001 From: MohammadReza Date: Sun, 25 Feb 2024 01:00:34 +0330 Subject: [PATCH] [Fixed] Check if nats connection is nil in `Drain()` Resolves #1562 --- nats.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nats.go b/nats.go index 0be428932..dc6b4b255 100644 --- a/nats.go +++ b/nats.go @@ -5314,6 +5314,9 @@ func (nc *Conn) drainConnection() { // // See note in Subscription.Drain for JetStream subscriptions. func (nc *Conn) Drain() error { + if nc == nil { + return ErrInvalidConnection + } nc.mu.Lock() if nc.isClosed() { nc.mu.Unlock()