-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors thrown inside of queue "completed" handler result in "Missing lock" errors #2213
Comments
Looks like thats the problem Lines 1092 to 1097 in 019d612
I modified the code; error not happening anymore const handleCompleted = result => {
return job.moveToCompleted(result, undefined, notFetch).then(jobData => {
try {
this.emit('completed', job, result, 'active');
} catch (err) {
// ignore
}
return jobData ? this.nextJobFromJobData(jobData[0], jobData[1]) : null;
});
}; |
Isn't it insane that emit can throw exceptions? Actually now that I read this issue I have a weak recall about this problem in another context. This is really insane if you think about it, and not the way you expect events should work, which its main feature is to decouple the event emitter from the event listeners... anyway, thanks for reporting. |
Yeah, i don't get it too. Thats why it took me hours to find the problem... |
@sysrun not sure that would solve the problem actually. The case at hand is when a non async listener throws an exception, as your code above demonstrates. Best would be to wrap emit so that it catches all possible exceptions that can be generated inside the listener. If the listener would have been async the throw will just be ignored. |
So an emit wrapper would catch possible exceptions and "redirect" them to the default "error" event? |
Yeah, thats what I am planing to do to fix this issue anyway. |
ahh, actually I fixed this on BullMQ already, I just forgot mostly about it: https://github.com/taskforcesh/bullmq/blob/master/src/classes/queue-base.ts#L51 |
## [4.1.1](v4.1.0...v4.1.1) (2021-11-16) ### Bug Fixes * **emit:** protect emit calls fixes [#2213](#2213) ([4978a2b](4978a2b))
🎉 This issue has been resolved in version 4.1.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This one gave me hours of pain...
Description
If an error is throw inside the queue "completed" handler, the queues "error" event will be triggered with "Error: Missing lock for job failed" and errorMessage "Error processing job".
Minimal, Working Test code to reproduce the issue.
After the second iteration the described error will be triggered
Bull version
4.1.0
The text was updated successfully, but these errors were encountered: