diff --git a/src/classes/queue-events.ts b/src/classes/queue-events.ts index 27201c26ca..1fdb028f50 100644 --- a/src/classes/queue-events.ts +++ b/src/classes/queue-events.ts @@ -48,9 +48,9 @@ export interface QueueEventsListener extends IoredisListener { /** * Listen to 'debounced' event. * - * This event is triggered when a job is debounced because debouncedId still existed. + * This event is triggered when a job is debounced because debounceId still existed. */ - debounced: (args: { jobId: string }, id: string) => void; + debounced: (args: { jobId: string; debounceId: string }, id: string) => void; /** * Listen to 'delayed' event. diff --git a/src/commands/includes/debounceJob.lua b/src/commands/includes/debounceJob.lua index b40f4cb8db..aa4cf089dd 100644 --- a/src/commands/includes/debounceJob.lua +++ b/src/commands/includes/debounceJob.lua @@ -15,7 +15,7 @@ local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKe if debounceKeyExists then local currentDebounceJobId = rcall('GET', debounceKey) rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", - "debounced", "jobId", currentDebounceJobId) + "debounced", "jobId", currentDebounceJobId, "debounceId", debounceId) return currentDebounceJobId end end diff --git a/tests/test_events.ts b/tests/test_events.ts index 41d99c2839..28bcade1f7 100644 --- a/tests/test_events.ts +++ b/tests/test_events.ts @@ -411,11 +411,13 @@ describe('events', function () { let debouncedCounter = 0; let secondJob; - queueEvents.on('debounced', ({ jobId }) => { + queueEvents.on('debounced', ({ jobId, debounceId }) => { if (debouncedCounter > 1) { expect(jobId).to.be.equal(secondJob.id); + expect(debounceId).to.be.equal('a1'); } else { expect(jobId).to.be.equal(job.id); + expect(debounceId).to.be.equal('a1'); } debouncedCounter++; });