elsa-workflows / elsa-workflows/elsa-core

[BUG] FlowJoin activity will only be run once which breaks loops in a Flowchart

Open
#6,229 4 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
If a workflow using the Flowchart activity has a loop which includes a FlowJoin inside of it, the Flowchart will only start the FlowJoin activity the first time it reaches that activity. On subsequent iterations of the loop the Flowchart will not start the FlowJoin activity once the preceding activity has been completed.

## Steps to Reproduce
1. Create a Workflow with a Flowchart which has a branch which loops around on itself, ensuring that the branch includes a FlowJoin activity within it.
2. Run the workflow, the first iteration around the loop will execute as expected.
3. The second iteration the Flowchart will essentially halt when it reaches the FlowJoin.

## Expected Behavior
The Flowchart will start the FlowJoin again in the second+ iteration of the loops.

## Actual Behavior
The Flowchart does not start the FlowJoin when it runs the second iteration of the loop.

## Environment
- **Elsa Package Version**: 3.2.3 (Works in version 3.1)

## Additional Context
The check added in #5544 appears to be what has broken this, as FlowJoin activity is added to the FlowScope on the first run, so it's seen as an existing activity when it comes time to start the second run.
From my understanding the check is added to handle the scenario where you have multiple activities feeding into a FlowJoin set to WaitAny, with the intention to avoid the FlowJoin kicking off twice.

Ideally to handle both scenarios the Flowchart would need to be able distinguish whether a parallel activity was joining to a FlowJoin that had already been run, or if it is coming from a chain of activities that have looped back around. I'm not sure if enough context is accessible or even recorded in the Flowchart.

As a workaround in our solution we've inherited the FlowJoin activity and added a behavior where we remove the FlowJoin activity from the FlowScope's activities collection, similar to #5742.

## Related Issues
https://github.com/elsa-workflows/elsa-core/pull/5544
https://github.com/elsa-workflows/elsa-core/issues/5487
https://github.com/elsa-workflows/elsa-core/issues/5742

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.