diff --git a/src/timekeeper.js b/src/timekeeper.js index bd666a0..13ec8a7 100644 --- a/src/timekeeper.js +++ b/src/timekeeper.js @@ -144,7 +144,7 @@ class Timekeeper extends EventEmitter { const scheduled = schedules .filter(i => this.shouldSendIt(i.cron, i.timezone)) .map(({ name, data, options }) => - ({ name: QUEUES.SEND_IT, data: { name, data, options }, singletonKey: name, singletonSeconds: 60 })) + ({ name: QUEUES.SEND_IT, data: { name, data, ...options }, singletonKey: name, singletonSeconds: 60 })) if (scheduled.length > 0 && !this.stopped) { await this.manager.insert(scheduled) diff --git a/test/scheduleTest.js b/test/scheduleTest.js index 2592aab..5c58b9c 100644 --- a/test/scheduleTest.js +++ b/test/scheduleTest.js @@ -34,6 +34,33 @@ describe('schedule', function () { await boss.stop({ graceful: false }) }) + it('should set job metadata correctly', async function () { + const config = { + ...this.test.bossConfig, + cronMonitorIntervalSeconds: 1, + cronWorkerIntervalSeconds: 1, + noDefault: true + } + + let boss = await helper.start(config) + const queue = this.test.bossConfig.schema + + await boss.createQueue(queue) + await boss.schedule(queue, '* * * * *', {}, { retryLimit: 42 }) + await boss.stop({ graceful: false }) + + boss = await helper.start({ ...config, schedule: true }) + + await delay(2000) + + const [job] = await boss.fetch(queue, { includeMetadata: true }) + + assert(job) + + assert.strictEqual(job.retryLimit, 42) + await boss.stop({ graceful: false }) + }) + it('should not enable scheduling if archive config is < 60s', async function () { const config = { ...this.test.bossConfig,