Skip to content

beforeEnqueue/afterEnqueue not called upon Retry #721

Open
@ehainer

Description

@ehainer

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions