Recurring jobs do not automatically get retried after application crash (.net core service)

Hi,
I am using hangfire (1.7.28) in a .NET 6 service with Hangfire.PostgreSql for storage.
Scheduling new jobs and executing/retrying them works fine as long as the service is running. If it crashes though none of the instances that where running at the time of the crash are getting retried on startup.
As far as i understand the documentation the expected behaviour would be that they rerun.

I am using custom states in case that matters but also experience the problem if the job is in the “Processing” state at time of the crash.

Here is my setup:

services.AddHangfire((provider, config) =>
{
config.UsePostgreSqlStorage(configurationRoot.GetValue<string>("DBConnectionString"))
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseFilter(new ElectStateFilter(provider.GetRequiredService<ConfigurationStorageProvider>(), provider.GetRequiredService<ILogger<ElectStateFilter>>())); 
});
services.AddHangfireServer();

GlobalStateHandlers.Handlers.Add(new RemoteJobInitiatedState.Handler());
GlobalStateHandlers.Handlers.Add(new RemoteJobProcessingInitiatedState.Handler());
GlobalStateHandlers.Handlers.Add(new RemoteJobTransferInitiatedState.Handler());
GlobalStateHandlers.Handlers.Add(new DatabaseInsertInitiatedState.Handler());

Looking at the hangfire db i can see the in-progress jobs in the table “job” but they are obviously not getting picked up again.

What am i missing?

Thanks

I found the reason why the retries were not working…

I had one dependency in my job class that was initially registered after the call to AddHangFire and AddHangfireServer. Registering it before the call fixed the issue.
It would be real nice if the server would log an error somewhere if it can´t construct the instance for the job execution.

For completeness sake here is an example of the issue and the fix

Job class constructor:

public HangFireJob(IDependency dep )
{
    _dep = dep;
}

Initial setup process that caused the issue:

services.AddHangfire((provider,config) =>
{ ... }
services.AddHangfireServer()
services.AddSingleton<IDependency>(new Dependency())

Working setup process:

services.AddSingleton<IDependency>(new Dependency())
services.AddHangfire((provider,config) =>
{ ... }
services.AddHangfireServer()