Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job.createBulk doesnt not obey custom jobID #189

Closed
willoughby opened this issue Apr 27, 2020 · 3 comments
Closed

Job.createBulk doesnt not obey custom jobID #189

willoughby opened this issue Apr 27, 2020 · 3 comments

Comments

@willoughby
Copy link

willoughby commented Apr 27, 2020

I have a set of jobs which I only ever want to be queued once at most.

const queue = [];

const services = await Services.find({
    uid: {
        $in: activeIds
    },
    active: true
});

for (const service of services) {
    try {
        queue.push({
            name: 'sync',
            data: {
                id: service._id.toString()
            },
            opts: {
                jobId: service._id.toString(),
                connection,
                priority: 1,
                removeOnComplete: true,
                removeOnFail: true,
                timeout: 30000,
            },
        });
    } catch (e) {
        console.log('Error Queueing services', e, e.stack);
    }

I have traced in createBulk in job.ts 88 its missing the 5th argument which allows the custom jobId

const jobInstances = jobs.map(
      job => new Job<T, R>(queue, job.name, job.data, job.opts, opts && opts.jobId),
);
@willoughby
Copy link
Author

Pull request #190

@manast
Copy link
Contributor

manast commented Apr 27, 2020

As I comment in the PR, it seems really strange to have job id as a fifth argument when it is already passed in the job options, I think this is what we need to improve and remove the fifth parameter alltogether, I do not have a valid explanation on to why it looks this way, maybe some copy/paste error from bull v3 but I am not sure.

pcashdown-tu added a commit to TallyUpTeam/bullmq that referenced this issue Jun 19, 2020
pcashdown-tu added a commit to TallyUpTeam/bullmq that referenced this issue Jun 20, 2020
pcashdown-tu added a commit to TallyUpTeam/bullmq that referenced this issue Jun 21, 2020
pcashdown-tu added a commit to TallyUpTeam/bullmq that referenced this issue Aug 24, 2020
@roggervalf
Copy link
Collaborator

passing a customId should be possible now as in this test case https://github.com/taskforcesh/bullmq/blob/master/tests/test_bulk.ts#L108-L139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants