Is the default name intended inside Worker processor
#23
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Good catch! This was a bug — fixed in What was happeningWhen This is different from The fixNow // Before (broken): name was lost
data: jobTemplate?.data ?? {}
// After (fixed): name is embedded in data
data: jobTemplate?.name
? { name: jobTemplate.name, ...(jobTemplate.data ?? {}) }
: (jobTemplate?.data ?? {})So now this works as expected: await queue.upsertJobScheduler('my-scheduler', {
every: 60000,
}, {
name: 'send-email', // ← will now appear as job.name in the worker
data: { to: 'user@test.com' },
});
const worker = new Worker('my-queue', async (job) => {
console.log(job.name); // 'send-email' (was 'default' before the fix)
}, { embedded: true });You no longer need the workaround of putting the name in Thanks for reporting @arthurvanl! |
Beta Was this translation helpful? Give feedback.


Good catch! This was a bug — fixed in
effd637.What was happening
When
upsertJobSchedulerregistered a cron job, it only storedjobTemplate.datawithout embedding thename. When the cron fired and pushed a job, the worker extractednamefromjob.data.name, found nothing, and fell back to'default'.This is different from
Queue.add(name, data), which correctly embeds the name into the data as{ name, ...data }.The fix
Now
upsertJobSchedulerembedsjobTemplate.nameinto the cron job data, matchingQueue.add()behavior: