Open cristianDrDr opened 2 months ago
Hi Cristian,
Have you considered using Hangfire or Quartz as the scheduling backend for your activities? It looks like the issue stems from the default Elsa scheduler, which uses System.Timers.Timer
to handle delays. The Timer class accepts intervals as an int, with a maximum value of 2,147,483,647. This translates to just under 25 days, which is causing the error you're encountering.
Description
Specifying the input value of 72:00:00 in the delay node creates a bookmark that has the resume at in 72 days in the elsa.bookmarks table but not on the instance. The impact is that the background service fails to process it and it crashes. Anything above 25 days seems to fail.
Steps to Reproduce
Add a delay node and add the value of 72:00:00 in the TimeSpan input. Run the workflow Restart the background service The background service fails to start back up with the error of Invalid value '6220688071.5474' for parameter 'interval'.
Expected Behavior
The background service processes the instance as per configuration
Actual Behavior
The background service crashes
Log Output
fail: Microsoft.Extensions.Hosting.Internal.Host[9] BackgroundService failed System.ArgumentException: Invalid value '6220688071.5474' for parameter 'interval'. at System.Timers.Timer..ctor(Double interval) at Elsa.Scheduling.ScheduledTasks.ScheduledSpecificInstantTask.Schedule() at Elsa.Scheduling.ScheduledTasks.ScheduledSpecificInstantTask..ctor(ITask task, DateTimeOffset startAt, ISystemClock systemClock, IServiceScopeFactory scopeFactory) at InvokeStub_ScheduledSpecificInstantTask..ctor(Object, Span
1) at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance[T](IServiceProvider provider, Object[] parameters) at Elsa.Scheduling.Schedules.SpecificInstantSchedule.Schedule(ScheduleContext context) at Elsa.Scheduling.Services.LocalScheduler.ScheduleAsync(String name, ITask task, ISchedule schedule, IEnumerable1 keys, CancellationToken cancellationToken) at Elsa.Scheduling.Services.LocalScheduler.ScheduleAsync(String name, ITask task, ISchedule schedule, CancellationToken cancellationToken) at Elsa.Scheduling.Services.DefaultWorkflowScheduler.ScheduleAtAsync(String taskName, DispatchWorkflowInstanceRequest request, DateTimeOffset at, CancellationToken cancellationToken) at Elsa.Scheduling.Services.DefaultBookmarkScheduler.ScheduleAsync(IEnumerable
1 bookmarks, CancellationToken cancellationToken)`Troubleshooting Attempts
Setting the format of the TimeSpan to 72.00:00:00 yields the same result but smaller values like 3.00:00:00 seem to work.