elsa-workflows / elsa-workflows/elsa-core

[BUG] Timer Trigger not respecting SingletoneStrategy

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

Description

## Description
The timer trigger does not seem to respect the `SingletoneStrategy`.

Elsa v3.1.3

## Steps to Reproduce
Due to a bug with the default scheduler where it doubles on each trigger instance I used the quartz scheduler.

```
// ...
elsa.UseQuartz();
elsa.UseScheduling(x => x.UseQuartzScheduler());
});

```

Using the `Elsa.Samples.AspNet.Heartbeats` project and updating the `HeartbeatWorkflow` to the following.

```
public class HeartbeatWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
builder.Root = new Sequence
{
Activities =
{
new Timer(5.Seconds())
{
CanStartWorkflow = true
},
new WriteLine(context => $"Start {context.GetRequiredService().UtcNow.TimeOfDay}"),
new Delay(10.Seconds()),
new WriteLine(context => $"Finish {context.GetRequiredService().UtcNow.TimeOfDay}"),
}
};

builder
.WithActivationStrategyType();
}
}
```

## Expected Behavior
This workflow should print out `Start ...` then `Finish ...` in sequence.

## Actual Behavior
Every 5 seconds a `Start ...` and a corresponding `Finish ...` is printed.

```
Start 09:13:13.7904393
Start 09:13:18.7184339
Start 09:13:23.7192477
Finish 09:13:23.8538843
Start 09:13:28.7107583
Finish 09:13:28.7340925
Start 09:13:33.7075519
Finish 09:13:33.7464776
Start 09:13:38.7213696
Finish 09:13:38.7266934
```

## Log Output
Include any relevant log output or error messages that might help diagnose the issue.

## Troubleshooting Attempts
This does not happen when I trigger the same work from `HttpEndpoint` trigger.

Contributor guide

Open the contributing guide

Research direction

Start with the Elsa.Samples.AspNet.Heartbeats project and its HeartbeatWorkflow reproduction, then trace how the Timer trigger invokes workflows when SingletonStrategy and the Quartz scheduler are configured. Reproduce the output using the issue's 5-second timer and 10-second delay; done means a new run does not start while the previous run is still active, while the HttpEndpoint behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.