jetstream
jetstream copied to clipboard
Handle unexpected return values
I noticed that we are using a very simple case statement to enforce the behaviour of the PullConsumer which means that if a user ever implements a function that has an unexpected return value it will crash their PullConsumer without sending back a NACK or any other indication to the jetstream server.
I think this type of thing could happen pretty easily by using a with statement in user code.
This seems like something we should handle by logging an error and potentially returning a NACK to jetstream, but we probably shouldn't just crash the whole PullConsumer?
Returning something unexpected is a programmer error, and personally I would throw tantrums from our code in such case because it's contract violation.
I do agree that raising a more meaningful exception is a good thing here to do.
I am not sure if we should send NACK back because:
- a stream may be configured in
NoAckmode for example - not sending anything is also a Jetstream-recognizable behaviour (as far as I know, I may be wrong) and it means that consumer encountered an internal error -- which is exactly the thing that happens here