-
-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Labels
Description
Hey,
I found an issue related with JobLock Plugin. By default, JobLock re-enqueues a job if its key was already set. If, for some reason, renqueue fails the error will be caught in here:
node-resque/src/core/worker.ts
Lines 295 to 314 in 708ea4a
| } catch (error) { | |
| this.error = error; | |
| if (!triedAfterPerform) { | |
| try { | |
| await RunPlugins( | |
| this, | |
| "afterPerform", | |
| job.class, | |
| this.queue, | |
| this.jobs[job.class], | |
| job.args | |
| ); | |
| } catch (error) { | |
| if (error && !this.error) { | |
| this.error = error; | |
| } | |
| } | |
| } | |
| return this.completeJob(!this.error, startedAt); | |
| } |
and afterPerform stage will be executed anyway. This will cause JobLock key to be deleted and it will completely break the plugin purpose because it immediately allows other jobs(that share the same key) to be executed concurrently.
Possible solutions:
- refactor
JoblockbeforePerform()stage to handle any possible errors when re-enqueing - don't call
RunPlugins('afterPerform')if job perform wasn't effectively called.
Cheers