Skip to content

Commit

Permalink
prevents a panic during shutdown when there's no NATS connection (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
autodidaddict authored Jul 1, 2024
1 parent e0b6499 commit c9aa165
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,11 @@ func (n *Node) shutdown() {
_ = n.publishNodeStopped()
}

_ = n.nc.Drain()
for !n.nc.IsClosed() {
time.Sleep(time.Millisecond * 25)
if n.nc != nil {
_ = n.nc.Drain()
for !n.nc.IsClosed() {
time.Sleep(time.Millisecond * 25)
}
}

if n.natspub != nil {
Expand Down

0 comments on commit c9aa165

Please sign in to comment.