danielgerlag / danielgerlag/workflow-core
OnStepErrorAsync, OnLifeCycleEventAsync
- Dominant language
- C#
- Stars
- 5.9k
- Forks
- 1.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 5
Description
**Is your feature request related to a problem? Please describe.**
The following code throws the following thread error:
```csharp
host.OnStepError += async (workflow, step, exception) =>
{
logger.LogError(exception, "Step error detected in workflow {WorkFlowId} on step id {StepId}, stopping host.", workflow.Id, step.Id);
MRE.Set();
await host.StopAsync(cts.Token).ConfigureAwait(false);
};
```
> ERROR - VSTHRD101Avoid using async lambda for a void returning delegate type, because any exceptions not handled by the delegate will crash the process
**Describe the solution you'd like**
Allow events that can take a Task instead of void.
**Describe alternatives you've considered**
Not awaiting:
```csharp
host.OnStepError += (workflow, step, exception) =>
{
logger.LogError(exception, "Step error detected in workflow {WorkFlowId} on step id {StepId}, stopping host.", workflow.Id, step.Id);
MRE.Set();
_ = host.StopAsync(cts.Token);
};
```
**Additional context**
Add any other context or screenshots about the feature request here.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the OnStepError and OnLifeCycleEventAsync event declarations and the code paths that invoke them. Trace how host.StopAsync is used by handlers and determine the expected behavior for awaiting Task-returning callbacks and handling callback exceptions. Done means the requested async event support is implemented consistently and the existing event behavior remains clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100