beforeEnqueue/afterEnqueue not called upon Retry
See original GitHub issuePretty 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:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
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/99Ping! Just checking in