Skip to content

Commit 6b38b66

Browse files
Copilotsfmskywalker
andcommitted
Fix dangling activity exception for multi-trigger flowcharts
Modified MaybeScheduleOutboundActivitiesAsync to handle activities that appear dangling from one trigger's perspective but were legitimately scheduled by another trigger. Now only throws exception if activity has no outbound connections. Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
1 parent be4b3bc commit 6b38b66

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.Counters.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,16 @@ private static async ValueTask<bool> MaybeScheduleOutboundActivitiesAsync(FlowGr
171171
{
172172
bool hasScheduledActivity = false;
173173

174+
// Get the outbound connections for this activity
175+
var outboundConnections = flowGraph.GetOutboundConnections(activity);
176+
174177
// Check if the activity is dangling (i.e., it is not reachable from the flowchart graph)
175-
if (flowGraph.IsDanglingActivity(activity))
178+
// Only throw an exception if the activity is truly dangling (has no outbound connections)
179+
// In multi-trigger scenarios, an activity may appear dangling from one trigger's perspective
180+
// but was legitimately scheduled by another trigger
181+
if (flowGraph.IsDanglingActivity(activity) && outboundConnections.Count == 0)
176182
{
177-
throw new($"Activity {activity.Id} is not reachable from the flowchart graph. Unable to schedule it's outbound activities.");
183+
throw new($"Activity {activity.Id} is not reachable from the flowchart graph and has no outbound connections. Unable to schedule it's outbound activities.");
178184
}
179185

180186
// Register the activity as visited unless it was executed due to a backward connection
@@ -184,7 +190,7 @@ private static async ValueTask<bool> MaybeScheduleOutboundActivitiesAsync(FlowGr
184190
}
185191

186192
// Process each outbound connection from the current activity
187-
foreach (var outboundConnection in flowGraph.GetOutboundConnections(activity))
193+
foreach (var outboundConnection in outboundConnections)
188194
{
189195
var connectionFollowed = outcomes.Names.Contains(outboundConnection.Source.Port);
190196
flowScope.RegisterConnectionVisit(outboundConnection, connectionFollowed);

0 commit comments

Comments
 (0)