danielgerlag / danielgerlag/workflow-core

Step execution order after Branch is completed

Open
#1,357 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
5.9k
Forks
1.3k
Avg merge
1d 1h
Merged PRs (30d)
5

Description

**Describe the bug**
If there is a registered step after .Decide step in a workflow, flow of execution is not as expected. If you add step after .Decide step, that step is executed right after first step from one of the branches, and not after whole branch is completed. How can I continue workflow after .Decide step?

**To Reproduce**
Add Step after .Decide step and start the workflow.

```
var branch1 = builder.CreateBranch()
.StartWith()
.Input(step => step.Message, data => "hi from 1")
.Then()
.Input(step => step.Message, data => "bye from 1");

var branch2 = builder.CreateBranch()
.StartWith()
.Input(step => step.Message, data => "hi from 2")
.Then()
.Input(step => step.Message, data => "bye from 2");

builder
.StartWith()
.Decide(data => data.Value1)
.Branch((data, outcome) => data.Value1 == "one", branch1)
.Branch((data, outcome) => data.Value1 == "two", branch2)
.Then()
.Input(step => step.Message, data => "Should be executed at the end.");
```

**Expected behavior**
Expected behavior if data.Value1 is set to "two":
- Expected output:
```
Hello
hi from 2
bye from 2
Should be executed at the end.
```

- Actual output:
```
Hello
hi from 2
Should be executed at the end.
bye from 2
```

**Additional context**
Screenshots:

![Image](https://github.com/user-attachments/assets/0f655e94-d839-42f5-9710-7cdebb5b9ea1)

![Image](https://github.com/user-attachments/assets/52c1371e-22eb-4dc5-8e73-cd1353f5eaf1)

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the workflow from the issue using the Decide, Branch, and following Then steps, and trace the branch execution order. Done means the selected branch completes both PrintMessage steps before the final PrintMessage runs, matching the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.