Closed vrohak closed 6 days ago
Hey @vrohak
Thanks for reporting the issue.
According to my current understanding, all job types should be registered during startup
That is correct. As we utilize the DI container, there are certain downsides and risks if the object doesn't live inside the container (trimming and performance would be some of the things).
In any case, as you "only" registering the type, that shouldn't lead to duplicated executions. That is clearly a bug.
I have a fix and will push a preview version soon
There will be a 3.3.6-preview
packages in a few minutes. A stable release will also come soon
Describe the bug
I have an IHostedService running in a Host app and want to be able to schedule recurring jobs during its runtime. Jobs can be of multiple types (for simplicity, let's call them XJob and YJob, where both implement the IJob interface).
According to my current understanding, all job types should be registered during startup, like mentioned here:
What I have noticed is that the one registered first (in this case XJob) gets run twice if I also add jobs through IRuntimeJobRegistry during runtime like this:
Minimal Reproducible Example: https://github.com/vrohak/ncronjob-bug-demo-1.git
NOTE: everything works fine if I add both jobs together like this:
Current behavior
Logs:
As you can see XJob gets executed twice, while YJob runs only once.
Expected behavior
It would be great if we had an agreed upon way of registering just the job types on startup so we can schedule the actual jobs during runtime.
Until then, adding jobs during runtime should at least be possible one by one, without causing duplication.
Version information