1
0
mirror of synced 2024-11-21 08:53:50 +00:00

Fixed: delete flowstate when Exception occurs

This commit is contained in:
Hans Mulder 2020-01-20 13:06:55 +01:00
parent ae2acc6614
commit 041cd1eea1
2 changed files with 9 additions and 2 deletions

View File

@ -36,9 +36,14 @@ namespace Tapeti.Flow.Default
await FlowStateLock.DeleteFlowState();
}
public bool IsStoredOrDeleted()
{
return storeCalled || deleteCalled;
}
public void EnsureStoreOrDeleteIsCalled()
{
if (!storeCalled && !deleteCalled)
if (!IsStoredOrDeleted())
throw new InvalidProgramException("Neither Store nor Delete are called for the state of the current flow. FlowID = " + FlowStateLock?.FlowID);
}

View File

@ -57,7 +57,9 @@ namespace Tapeti.Flow.Default
if (flowContext?.FlowStateLock != null)
{
if (consumeResult == ConsumeResult.Error)
if (!flowContext.IsStoredOrDeleted())
// The exception strategy can set the consume result to Success. Instead, check if the yield point
// was handled. The flow provider ensures we only end up here in case of an exception.
await flowContext.FlowStateLock.DeleteFlowState();
flowContext.FlowStateLock.Dispose();