Skip to content

Commit

Permalink
jetstream: ordered consumer: handle closed subscriptions gracefully
Browse files Browse the repository at this point in the history
In `orderedConsumer.reset()`, we return from the `retryWithBackoff()`
function with `false, nil` in case the subscription is closed. In this case,
the `var cons Consumer` is still nil, and we crash in the attempt to cast it
to a `pullConsumer` later on.

Fix this by catching that `nil` case explicitly.
  • Loading branch information
zonque committed Jun 25, 2024
1 parent 370bc4f commit f28e14a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jetstream/ordered.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ func (c *orderedConsumer) reset() error {
if err != nil {
return err
}
if cons == nil {
return nats.ErrSubscriptionClosed
}
c.currentConsumer = cons.(*pullConsumer)
return nil
}
Expand Down

0 comments on commit f28e14a

Please sign in to comment.