2021-05-18 01:52:58.347 -04:00 [INF] Triggered event "Disconnect" from state "SavingIdle" to "SavingDisconnected"
2021-05-18 01:53:02.990 -04:00 [INF] Triggered event "Save" due to "Save" from state "SavingIdle" to "IdleSaved"
In this case, final state should be IdleDisconnected instead of IdleSaved.
This gets even more tricky when reverting happen because reverting is current handled by remembering the initial state, which can change due to the event sequences.
Triggered event "RequestLoading" due to "Load" from state "DisconnectedEmpty" to "LoadingDisconnected"
Triggered event "Connect" from state "LoadingDisconnected" to "LoadingIdle"
Triggered event "Load" due to "Load" from state "LoadingDisconnected" to null
# Transition from "LoadingDisconnected" by "Load" was cancelled! Revert back to orignal state "DisconnectedEmpty". #
Long running processing is included in the transition, which means there is a sequence of logic that can cause race condition easily: get the current state -> identify the transition -> long processing -> change to end state.
Saving/Loading
Confirmation dialog
Reverting (Cancelling) is done by remembering the initial state and reset to that state if the transition is cancelled. Another separate transition that happen between the initial transition and the cancellation will invalidate the cached initial state.
Problem Description
In this case, final state should be IdleDisconnected instead of IdleSaved.
This gets even more tricky when reverting happen because reverting is current handled by remembering the initial state, which can change due to the event sequences.
Right now:
IdleUnsaved --Save--> SavingIdle --Disconnect--> SavingDisconnected --Cancel(Revert)--> IdleUnsaved
DisconnectedEmpty --Load--> LoadingDisconnected --Connect--> LoadingIdle --Cancel(Revert)--> DisconnectedEmpty
Sample logs:
Expected:
IdleUnsaved --Save--> SavingIdle --Disconnect--> SavingDisconnected --Cancel(Revert)--> DisconnectedUnsaved
Root Causes