bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

[Misleading Documentation] The Job Schedulers id that the documentation refers to is the `key` field

Open Chee7ah opened this issue 11 months ago • 1 comments

The issue is that the jobSchedulers don't have an id property that the docs seemingly talk about, they have a key property. Example jobScheduler retrieved by getJobSchedulers:

Image

The documentation talks about ids:

const firstJob = await queue.upsertJobScheduler('my-scheduler-id', {
  every: 1000,
});
// Remove a job scheduler with ID 'scheduler-123'
const result = await queue.removeJobScheduler('scheduler-123');
console.log(
  result ? 'Scheduler removed successfully' : 'Missing Job Scheduler',
);
removeJobScheduler(jobSchedulerId): Promise<boolean>

The getJobScheduler method retrieves a job scheduler by id. This is invaluable for inspecting dedicated configurations.

const scheduler = await queue.getJobScheduler('test');
console.log('Current job scheduler:', scheduler);
getJobScheduler(id): Promise<JobSchedulerJson<DataType>>

And after all that, there is an optional id property on the jobScheduler:

interface JobSchedulerJson<D> {
    endDate?: number;
    every?: string;
    id?: string;
    iterationCount?: number;
    key: string;
    limit?: number;
    name: string;
    next?: number;
    pattern?: string;
    template?: JobSchedulerTemplateJson<D>;
    tz?: string;
}

What is referred to as id everywhere in the documentation, is the key in the actual data. Calling removeJobScheduler with jobScheduler.key is what is working.

Chee7ah avatar Apr 27 '25 02:04 Chee7ah

https://github.com/taskforcesh/bullmq/blob/5252f22546370f80531e48199ca74e902d8804e7/src/interfaces/job-scheduler-json.ts

There is a comment that says "key is actually the job scheduler id" next to the key field.

Should we update the variable name or improve the documentation?

ltyiz07 avatar May 23 '25 07:05 ltyiz07