elsa-workflows / elsa-workflows/elsa-core

[BUG] Elsa3 ParallelForEach faults OnChildComplete, if Inner flow includes any blocking activity!

Open
#6,181 0 comments 1 reaction 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

**Quick summary and/or background**
I'm contemplating incorporating elsa3 in a project that I'm working on, currently validating through a POC which involves some custom blocking activities that produce bookmarks, as documentation is still work in progress, i got used to examining the source code to try to figure things out on my own, for example (passing callbacks when creating bookmarks)so far so good. Until I ran into a scenario where i have to use ParallelForEach Activity.

**I'm using **
Elsa 3.23 packages with server persistence EF Postgres (Although i doubt that it's relevant)

My theory based on what i understood from the source, is that ParallelForEach maintains a list of tags List and assigns each child loop an Guid tag, on child complete , the main activity (ParallelForEach) tracks if any other children are still active and needs to obtain the variable (either from runtime memory or persistance, depending if it got suspended or not) when it needs to suspent the serialization process is bugged where its unable to deserialize it back to List and an exception is thrown originating from https://github.com/elsa-workflows/elsa-core/blob/ff0b5ee06c6b04ba24ee2c0f42aa9b7aa9151802/src/modules/Elsa.Expressions/Helpers/ObjectConverter.cs#L127

**Steps to reproduce**
1. In designer, create a simple workflow definition that includes only one ParallelForEach activity, pass any input list in it's item to have it run some child activities.
2. Inside the body of ParallelForEach add a Delay activity with any timespan (the body needs to be blocking activity to put the flow in suspend and force it to store it's variables in store)
3. run an instance

**Expected**
The flow runs to completion

**What actually happens**
Right after the a delay completes the activity is faulted with
```
Elsa.Expressions.Exceptions.TypeConversionException

Failed to deserialize {"$values":["5f2d3133-ec5e-47ec-98a9-b8a3363ad936","709392ce-55e7-4b97-9e5f-a6c303c21201"],"_type":"Guid[]"} to System.Collections.Generic.List`1[System.Guid]

Elsa.Expressions.Helpers.ObjectConverter.ConvertTo(Object value, Type targetType, ObjectConverterOptions converterOptions) at
Elsa.Expressions.Helpers.ObjectConverter.ConvertTo(Object value, Type targetType, ObjectConverterOptions converterOptions) at
Elsa.Expressions.Helpers.ObjectConverter.ConvertTo[T](Object value, ObjectConverterOptions converterOptions) at
Elsa.Extensions.DictionaryExtensions.ConvertValue[T](Object value) at
Elsa.Extensions.DictionaryExtensions.TryGetValue[TKey,T](IDictionary`2 dictionary, TKey key, T& value) at
Elsa.Extensions.DictionaryExtensions.TryGetValue[T](IDictionary`2 dictionary, String key, T& value) at
Elsa.Workflows.ActivityExecutionContext.GetProperty[T](String key) at
Elsa.Workflows.Activities.ParallelForEach`1.OnChildCompleted(ActivityCompletedContext context) at
Elsa.Workflows.Behaviors.ScheduledChildCallbackBehavior.OnActivityCompletedAsync(ActivityCompleted signal, SignalContext context) at
Elsa.Workflows.Behavior.Elsa.Workflows.Contracts.ISignalHandler.ReceiveSignalAsync(Object signal, SignalContext context) at
Elsa.Workflows.Activity.Elsa.Workflows.Contracts.ISignalHandler.ReceiveSignalAsync(Object signal, SignalContext context) at
Elsa.Extensions.ActivityExecutionContextExtensions.SendSignalAsync(ActivityExecutionContext context, Object signal) at
Elsa.Workflows.ActivityExecutionContext.CompleteActivityAsync(Object result) at
Elsa.Workflows.Activities.Flowchart.Activities.Flowchart.OnChildCompletedAsync(ActivityCompletedContext context) at
Elsa.Workflows.Behaviors.ScheduledChildCallbackBehavior.OnActivityCompletedAsync(ActivityCompleted signal, SignalContext context) at
Elsa.Workflows.Behavior.Elsa.Workflows.Contracts.ISignalHandler.ReceiveSignalAsync(Object signal, SignalContext context) at
Elsa.Workflows.Activity.Elsa.Workflows.Contracts.ISignalHandler.ReceiveSignalAsync(Object signal, SignalContext context) at
Elsa.Extensions.ActivityExecutionContextExtensions.SendSignalAsync(ActivityExecutionContext context, Object signal) at
Elsa.Workflows.ActivityExecutionContext.CompleteActivityAsync(Object result) at
Elsa.Workflows.Behaviors.AutoCompleteBehavior.ExecuteAsync(ActivityExecutionContext context) at
Elsa.Workflows.Behavior.Elsa.Workflows.Contracts.IBehavior.ExecuteAsync(ActivityExecutionContext context) at
Elsa.Workflows.Activity.Elsa.Workflows.Contracts.IActivity.ExecuteAsync(ActivityExecutionContext context) at
Elsa.Workflows.Middleware.Activities.DefaultActivityInvokerMiddleware.ExecuteActivityAsync(ActivityExecutionContext context) at
Elsa.Workflows.Runtime.Middleware.Activities.BackgroundActivityInvokerMiddleware.ExecuteActivityAsync(ActivityExecutionContext context) at
Elsa.Workflows.Middleware.Activities.DefaultActivityInvokerMiddleware.InvokeAsync(ActivityExecutionContext context) at
Elsa.Workflows.Middleware.Activities.Notificat
ionPublishingMiddleware.InvokeAsync(ActivityExecutionContext context) at
Elsa.Workflows.Middleware.Activities.ExecutionLogMiddleware.InvokeAsync(ActivityExecutionContext context)
```

Thank you very much for your efforts and a great project!

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.