Making a BullMQ processor safe to run twice #4543
violetta98
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
"My job ran twice" usually isn't a BullMQ bug. A job stalls and comes back, a worker dies mid-job, someone re-adds the same
jobId. The fix is an idempotent processor, which is harder to get right than it looks.Dedupes on
job.id. The lease is derived from yourlockDurationand kept shorter, so the claim expires before BullMQ decides the job stalled. Attempts come fromjob.attemptsMade, so the count survives a worker restart.Same library covers HTTP endpoints and plain function calls, on Redis, Postgres, Mongo or DynamoDB. Apache-2.0: https://github.com/idemkit/idemkit
If you find it useful, a star would be much appreciated.
All reactions