Skip to content

Commit

Permalink
errors in status event - workflow keeps running (#7)
Browse files Browse the repository at this point in the history
When a error occurs in status event handler of a parent task
the error handler incorrectly sets the sending task to failed and not the parent task.
  • Loading branch information
fw2568 authored Oct 25, 2023
1 parent 480d2fa commit 92dd03c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ public async Task Handle(IFailed<T> failedMessage)
failedMessage.Message.TaskId, failedMessage.ErrorDescription
);

var failedTaskId = failedMessage.Message.TaskId;

// assign errors on status events to initiating task
if(failedMessage.Message is IOperationTaskStatusEvent statusEvent)
failedTaskId = statusEvent.InitiatingTaskId;

await _operationMessaging.DispatchTaskStatusEventAsync(
OperationTaskStatusEvent.Failed(
failedMessage.Message.OperationId, failedMessage.Message.InitiatingTaskId,
failedMessage.Message.TaskId, new ErrorData() { ErrorMessage = failedMessage.ErrorDescription },
failedTaskId, new ErrorData() { ErrorMessage = failedMessage.ErrorDescription },
_workflowOptions.JsonSerializerOptions));


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Dbosoft.Rebus.Operations.Events;

#nullable enable
public class OperationTaskStatusEventBase : IOperationTaskMessage
public class OperationTaskStatusEventBase : IOperationTaskStatusEvent
{
public OperationTaskStatusEventBase() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ public interface IOperationTaskMessage

Guid TaskId { get; }
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Dbosoft.Rebus.Operations;

public interface IOperationTaskStatusEvent : IOperationTaskMessage
{

}

0 comments on commit 92dd03c

Please sign in to comment.