Skip to content

✨ Add reEnqueue() functionality to exposed API#22

Merged
dodoarg merged 6 commits into
mainfrom
expose-atomic-reenqueue
Jul 23, 2026
Merged

✨ Add reEnqueue() functionality to exposed API#22
dodoarg merged 6 commits into
mainfrom
expose-atomic-reenqueue

Conversation

@dodoarg

@dodoarg dodoarg commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Adds MongoDBQueue#reEnqueue(ack), which atomically resets a message's tries and ack and makes it immediately visible in a single findOneAndUpdate, without inserting a new document.

Note

Technically, ping(ack, { resetTries: true, resetAck: true, visibility: 0 }) should be functionally equivalent, however ping actually coalesces visibility: 0 to the original config value by || operator (unclear whether this was intentional or not); either way, the intent of ping isn't that of re-enqueuing a message, so I decided to expose a new option-free API whose purpose is explicit to consumers. The implementation details that are shared with ping have been refactored into a small helper.

Test notes

Because this is needed for step 3 of #1915 I installed these changes locally and verified the new exposed API works as intended against its first consumer.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an explicit MongoDBQueue#reEnqueue(ack) API to atomically “put back” an in-flight message (resetting ack and tries and making it immediately visible) via a single findOneAndUpdate, primarily to support graceful-shutdown workflows without creating a new document.

Changes:

  • Added MongoDBQueue#reEnqueue() and refactored shared ack/ping update logic into a new private updateByAck() helper.
  • Added a dedicated re-enqueue test suite and updated test setup to clear the new collection.
  • Documented .reEnqueue() in the README and bumped the package version to 8.3.0.

Reviewed changes

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

Show a summary per file
File Description
test/setup.js Adds the re-enqueue collection to the test cleanup list.
test/re-enqueue.js Introduces tests validating reEnqueue() behavior and error cases.
README.md Documents the new .reEnqueue() API and contrasts it with .ping().
package.json Bumps version to 8.3.0.
mongodb-queue.ts Implements reEnqueue() and refactors ack/ping through updateByAck().

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

Comment thread test/re-enqueue.js
Comment thread README.md Outdated
@dodoarg dodoarg changed the title ✨ Expose atomic reEnqueue() for graceful-shutdown requeues ✨ Add reEnqueue() functionality to exposed API Jul 22, 2026
dodoarg and others added 2 commits July 22, 2026 12:49
copilot said so

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dodoarg
dodoarg marked this pull request as ready for review July 22, 2026 10:54
@dodoarg
dodoarg requested a review from alecgibson July 22, 2026 10:55
@dodoarg
dodoarg merged commit d7f05b5 into main Jul 23, 2026
3 checks passed
@dodoarg
dodoarg deleted the expose-atomic-reenqueue branch July 23, 2026 08:53
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.

3 participants