elsa-workflows / elsa-workflows/elsa-core

[BUG]Finished executing Fork with asynchronous activities unexpectedly

Open
#5,956 0 comments 0 reactions 0 assignees View on GitHub
bug triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

## Description
To execute activities of `Fork` in parallel, I marked activities as `Task` and set `RunAsynchronous` to be true. But the workflow contains the fork finished with `Suspended` status unexpectedly and didn’t execute any activity in `Fork`.

## Steps to Reproduce
1. **Sample Code**:
```c#
Sequence seq = new()
{
Activities = {
new Fork()
{
Branches =
{
new Do(c =>
{
Thread.Sleep(1000);
Console.WriteLine(“13”);
}) { RunAsynchronously = true },

new Do(c =>
{
Console.WriteLine(“11”);
Thread.Sleep(2000);
Console.WriteLine(“15”);
}) { RunAsynchronously = true },

new Do(c =>
{
Thread.Sleep(100);
Console.WriteLine(“12”);
}) { RunAsynchronously = true },
}
},
new Do(c => Console.WriteLine(“2”),
}
};

var services = new ServiceCollection();
var provider = services.BuildServiceProvider();
var runner = provider.GetRequiredService();

var r = await runner.RunAsync(seq);

[Activity(“Elsa”, Kind = ActivityKind.Task)]
public class Do : Inline
{
public Do(Action action)
: base(action)
{ }
}
```

## Expected Behavior
The workflow was supposed to execute activities of ‘Fork` in parallel.

## Actual Behavior
None of activities in `Fork` are executed. The workflow contains the `Sequence` ran into `Suspended` status and met 3 bookmarks which are related to 3 activities in `Fork`.

## Environment
- **Elsa Package Version**: 3.1.3
- **Operating System**: Windows 10

## Log Output
Include any relevant log output or error messages that might help diagnose the issue.

## Related Issues
Also, Can `Fork` finish after its activities executed in parallel which looks like `Task.WaitAll()` or `Task.WaitAny()`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.