Skip to content

Commit

Permalink
[FIXED] Protect against potential panics
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Piotrowski <[email protected]>
  • Loading branch information
piotrpio committed Jan 12, 2025
1 parent 1e1519f commit 06628de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jetstream/jetstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ func (js *jetStream) StreamNames(ctx context.Context, opts ...StreamListOpt) Str
for _, opt := range opts {
if err := opt(&streamsReq); err != nil {
l.err = err
close(l.streams)
close(l.names)
return l
}
}
Expand Down
6 changes: 3 additions & 3 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -4685,14 +4685,14 @@ func (s *Subscription) Unsubscribe() error {
// checkDrained will watch for a subscription to be fully drained
// and then remove it.
func (nc *Conn) checkDrained(sub *Subscription) {
if nc == nil || sub == nil {
return
}
defer func() {
sub.mu.Lock()
defer sub.mu.Unlock()
sub.draining = false
}()
if nc == nil || sub == nil {
return
}

// This allows us to know that whatever we have in the client pending
// is correct and the server will not send additional information.
Expand Down

0 comments on commit 06628de

Please sign in to comment.