Skip to content

Conversation

Copy link

Copilot AI commented Oct 29, 2025

The documentation for the deduplicated event incorrectly stated that jobId refers to the attempted job and deduplicatedJobId refers to the existing job. The actual behavior is reversed.

Changes

  • TypeScript API docs (src/classes/queue-events.ts): Corrected parameter descriptions

    • jobId: job that was attempted to be added → job that will be retained
    • deduplicatedJobId: existing job that caused deduplication → job that will be discarded
    • Updated event description to note it fires both when a new job is rejected AND when an existing job is replaced (via replace option)
  • User guide (docs/gitbook/guide/jobs/deduplication.md): Updated example and parameter list to match corrected behavior

Example

queueEvents.on('deduplicated', ({ jobId, deduplicationId, deduplicatedJobId }, id) => {
  // jobId = the job that survives (either old or new, depending on 'replace' option)
  // deduplicatedJobId = the job that gets discarded
  console.log(`Job ${deduplicatedJobId} was discarded. Job ${jobId} was retained`);
});

Verified against Lua implementation in src/commands/includes/deduplicateJob.lua where the parameters are emitted.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • badhost
    • Triggering command: /usr/local/bin/node --trace-warnings /home/REDACTED/work/bullmq/bullmq/node_modules/mocha/lib/cli/cli.js tests/test_deduplication.ts ./tests/test_*.ts --require /home/REDACTED/work/bullmq/bullmq/node_modules/ts-mocha/src/index.js --no-config --no-package --exit --file ./mocha.setup.ts --timeout 4000 --diff --extension js --extension cjs --extension mjs --reporter spec --slow 75 --ui bdd --watch-ignore node_modules --watch-ignore .git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: Docs are incorrect for deduplicated queue event parameters</issue_title>
<issue_description>### Version

v5.61.0

Platform

NodeJS

What happened?

See the docs for the deduplicated event:

  /**
   * Listen to 'deduplicated' event.
   *
   * This event is triggered when a job is not added to the queue because a job with the same deduplicationId
   * already exists.
   *
   * @param args - An object containing details about the deduplicated job.
   *  - `jobId` - The unique identifier of the job that was attempted to be added.
   *  - `deduplicationId` - The deduplication identifier that caused the job to be deduplicated.
   *  - `deduplicatedJobId` - The unique identifier of the existing job that caused the deduplication.
   * @param id - The identifier of the event.
   */
  deduplicated: (
    args: { jobId: string; deduplicationId: string; deduplicatedJobId: string },
    id: string,
  ) => void;

It says that jobId refers to the "job that was attempted to be added" while deduplicatedJobId refers to "the existing job that caused the deduplication". But it's actually the other way around. In my testing, deduplicatedJobId always refers to the job that will be discarded due to the duplication.

Also, I think it would be better not to refer to the order of the jobs here, since the deduplication.replace job param can be used to cause a newer job to replace the older, existing one.

So I suggest these docs instead:

  • jobId - The unique identifier of the job that will be retained.
  • deduplicatedJobId - The unique identifier of the job that will be discarded.

Also this description is not quite accurate

This event is triggered when a job is not added to the queue because a job with the same deduplicationId already exists.

It should probably be

This event is triggered when a job is not added to the queue because a job with the same deduplicationId already exists. It is also triggered when an existing job is discarded from the queue because a new job with the same deduplicationId is about to replace it.

How to reproduce.

No response

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

The documentation incorrectly stated that jobId refers to the job that
was attempted to be added and deduplicatedJobId refers to the existing
job. The actual behavior is the opposite:
- jobId: The job that will be retained
- deduplicatedJobId: The job that will be discarded

Also updated the event description to clarify it fires both when a job
is not added due to an existing duplicate and when an existing job is
replaced by a new one (when using the replace option).
Copilot AI changed the title [WIP] Fix incorrect documentation for deduplicated event parameters docs: fix deduplicated event parameter descriptions Oct 29, 2025
Copilot AI requested a review from manast October 29, 2025 18:17
Copilot finished work on behalf of manast October 29, 2025 18:17
@manast manast requested review from Copilot and roggervalf October 31, 2025 10:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the documentation for the deduplicated event to clarify the semantics of jobId and deduplicatedJobId parameters. The changes address ambiguity in the event's documentation by explicitly stating that this event fires both when a new job is rejected due to an existing duplicate and when an existing job is replaced by a new one.

  • Updated the event description to include both deduplication scenarios (rejection and replacement)
  • Clarified parameter meanings: jobId refers to the retained job, deduplicatedJobId refers to the discarded job
  • Updated example code and parameter descriptions in both code comments and documentation to reflect these clarifications

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/classes/queue-events.ts Updated JSDoc comments for the deduplicated event to clarify the dual nature of the event and the semantics of jobId vs deduplicatedJobId parameters
docs/gitbook/guide/jobs/deduplication.md Updated documentation examples and parameter descriptions to match the clarified event semantics
Comments suppressed due to low confidence (1)

docs/gitbook/guide/jobs/deduplication.md:86

  • The description of the deduplicated event states it's emitted when a job is 'ignored', but based on the updated JSDoc comments (lines 89-90), the event is also triggered when an existing job is discarded/replaced. This section should be updated to mention both scenarios: when a new job is ignored AND when an existing job is replaced, to match the updated technical documentation.
The **deduplicated** event is emitted whenever a job is ignored due to deduplication in either Simple Mode or Throttle Mode. This event allows you to monitor deduplication activity and take action if needed, such as logging the occurrence or notifying a user that their request was ignored.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@manast manast marked this pull request as ready for review November 3, 2025 09:48
@manast manast requested a review from Copilot November 3, 2025 09:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

docs/gitbook/guide/jobs/deduplication.md:86

  • This statement says the deduplicated event is only emitted in Simple Mode or Throttle Mode. However, the updated documentation in the TypeScript file (lines 89-90) and the examples below (lines 108-110) indicate the event is also emitted in Debounce Mode when replace: true. This section should be updated to mention that the event is also emitted when an existing job is replaced in Debounce Mode with the replace option.
The **deduplicated** event is emitted whenever a job is ignored due to deduplication in either Simple Mode or Throttle Mode. This event allows you to monitor deduplication activity and take action if needed, such as logging the occurrence or notifying a user that their request was ignored.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 88 to +90
* This event is triggered when a job is not added to the queue because a job with the same deduplicationId
* already exists.
* already exists. It is also triggered when an existing job is discarded from the queue because a new job
* with the same deduplicationId is about to replace it.
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated documentation describes that this event is triggered for both Simple/Throttle Mode (job rejection) and Debounce Mode with replace (job replacement). However, based on the Lua implementation in deduplicateJob.lua, the jobId and deduplicatedJobId parameters have opposite meanings in these two scenarios. In replace mode (line 17-18 of deduplicateJob.lua), jobId is the new job being added and deduplicatedJobId is the old job being removed. In normal dedup mode (lines 96-97), jobId is the existing job and deduplicatedJobId is the new job being rejected. The documentation at lines 93 and 95 states that jobId is 'the job that will be retained' and deduplicatedJobId is 'the job that will be discarded', which is only accurate for the replace scenario. This inconsistency should be documented or the implementation should be made consistent.

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

[Bug]: Docs are incorrect for deduplicated queue event parameters

2 participants