Skip to content

Possible bugs in HangfireJobScheduler #1104

@hainguyenthanh

Description

@hainguyenthanh

I'm using EventFlow v1.2.1 together with Hangfire and PostgreSQL. When the application scheduled a job using await jobScheduler.ScheduleAsync(job, runAt, cancellationToken) with runAt of 90 days in the future, the job executed immediately instead of executing at runAt. Reviewing the source code of the HangfireJobScheduler's ScheduleAsync method, I see that if _queueName is null, the job is enqueued by calling _backgroundJobClient.Enqueue(ExecuteMethodCallExpression(jobDefinition, json)) instead of calling _backgroundJobClient.Schedule(). As a result, the runAt argument is not passed to the Hangfire background job. And reviewing the Hangfire's _backgroundJobClient.Enqueue extension method, I see that the method enqueues to job to be executed immediately. This behaviour matches the issue I saw in my application.

In summary, calling _backgroundJobClient.Enqueue without using the runAt argument causes the Hangfire job to execute immediately.

Moreover, there could be the same bug in the HangfireJobScheduler's ScheduleAsync(IJob job, TimeSpan delay, CancellationToken cancellationToken) method.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions