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()