jetstream icon indicating copy to clipboard operation
jetstream copied to clipboard

Handle unexpected return values

Open mmmries opened this issue 3 years ago • 1 comments
trafficstars

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?

mmmries avatar Mar 26 '22 08:03 mmmries

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:

  1. a stream may be configured in NoAck mode for example
  2. 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

mkaput avatar Mar 29 '22 09:03 mkaput