question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

beforeEnqueue/afterEnqueue not called upon Retry

See original GitHub issue

Pretty obvious why neither of these events are emitted when the Retry plugin re-enqueues a job:

The Queue#enqueue method emits both, but the logic for the retry plugin includes a call to Queue#enqueueIn which in turn calls Queue#enqueueAt, which does not emit either event.

The main issue I’m trying to overcome is to manipulate the args passed to perform before/after a job runs. Specifically, I’d like to pass a Sequelize model instance as an arg, but normally when it’s serialized you obviously lose the instance and are left with just a plain object. To that end, I wanted to implement an interceptor like so:

beforeEnqueue() {
  // iterate through args, convert anything that is instanceof Model to 'gid://<Model Name>/<ID>'
}

beforePerform() {
  // iterate through args, anything that starts with 'gid://' is converted back to the instance
}

The above works fine on the first attempt at the job, but if the job fails and is retried, beforeEnqueue is not called and the resulting arg is serialized normally, and I have just a sad plain object 😦

Unless there is an alternative, glaringly obvious way to achieve my goal that I missing… Open to ideas.

Thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
evantahlercommented, Dec 14, 2021

I think I’d like to keep Object.freeze - the immutability of what’s passed to the job probably should be maintained. It’s an old 2015 issue, but it prevents these kind of problems - https://github.com/actionhero/node-resque/issues/99

0reactions
evantahlercommented, Jan 24, 2022

Ping! Just checking in

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Enqueue callback not called - Stack Overflow
You have empty onFailure implementation so callback may be called but nothing happens. Try to log some information in onFailure method.
Read more >
Recommended retry for ENQUEUE process - SAP Community
Hi Experts,. I'm planning to put a retry when failing to get a lock object in my ABAP program. I know that we...
Read more >
Support explicitly failing a job and sending to the dead queue
It's fine but it means the job does not go into the dead queue where I could inspect it later and easily see...
Read more >
Rails 7 ActiveJob adds the ability to communicate enqueue ...
This is achieved by yielding given block after the enqueue method is executed but before the result is returned.
Read more >
Enqueue a new job if last retry fail - Hangfire Discussion
I have a job that calls a web service and as always that could fail, I want to send an email when the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found