Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ameer-samad opened this issue Dec 5, 2024 · 0 comments

Comments

@ameer-samad
Copy link

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

return JsonSerializer.Deserialize(stringValue, underlyingTargetType, serializerOptions);

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant