-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Exception from OnEntry action should not result in queued trigger being executed after next trigger #267
Comments
What was the weird behaviour, and what was the expected behaviour. Exception handling can be hard to get right, and at the moment it is up to the user of stateless to deal with that problem. Different users will having different exception handling needs so it's tricky to cater for all possible requirements, so I'd like to leave as much as possible of the exception handling to the user. But as a compromise we could add a OnException method where we can assign an action, very much like the OnUnhandledTrigger method. We could also provide a way of clearing the trigger queue. Maybe also add an OnError handler for each state configuration as well? What do you think? |
@HenningNT The weird behaviour was:
While the current behaviour does not seem right, I am struggling with what the expected behaviour should be. After an unhandled exception I think any remaining queued triggers should either:
|
@gerardog You mentioned you stopped using OnEntry actions in your comment here: May I ask how you would design a stateless state machine when you have the following requirements:
|
@Snaaio, in your case I would wrap all stm.Fire() method calls inside a wrapper function, lets call it FireTrigger(). Inside it I would: (untested, just pseudocode)
This way you don't have to deal with the internal trigger queue from Stateless, which you mentioned that has issues when an exception is triggered. |
… if uncugth exception in trigger handler disrupts trigger execution. Ref issue #267.
I'm fixing the out-of-order trigger execution, but leaving the error handling untouched. |
I would like to design a state machine in which an exception thrown from an OnEntry action can propagate to the caller firing the trigger. Unfortunately I saw some weird behavior regarding the queuing of triggers.
As a workaround I upgraded to Stateless v4.2.0 and configured my statemachine to use FiringMode.Immediate, but it would be nice to see the default FiringMode.Queued play a bit nicer with exceptions being thrown.
Possible options to better handle this:
Add new method(s) on StateMachine to:
A. Fire queued triggers
B. Clear queued triggers
The text was updated successfully, but these errors were encountered: