-
Notifications
You must be signed in to change notification settings - Fork 413
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
perf(worker): fetch next job on failure #2342
Changes from 5 commits
ddcab8c
c136051
cd1787d
e084ba1
ff86754
d4cd189
697cd26
c7306bc
4bfe55b
541a333
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -715,8 +715,14 @@ export class Worker< | |
return; | ||
} | ||
|
||
await job.moveToFailed(err, token); | ||
const failed = await job.moveToFailed(err, token, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "failed" here is misleading, as this includes the next job to process. Should be called probably "result" or similar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good to me |
||
this.emit('failed', job, err, 'active'); | ||
|
||
if (failed) { | ||
const [jobData, jobId, limitUntil, delayUntil] = failed || []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. || [] is redundant as it is already checking if failed is truthy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
this.updateDelays(limitUntil, delayUntil); | ||
return this.nextJobFromJobData(jobData, jobId, token); | ||
} | ||
} catch (err) { | ||
this.emit('error', <Error>err); | ||
// It probably means that the job has lost the lock before completion | ||
|
@@ -735,7 +741,7 @@ export class Worker< | |
const result = await this.callProcessJob(job, token); | ||
return await handleCompleted(result); | ||
} catch (err) { | ||
return handleFailed(<Error>err); | ||
return await handleFailed(<Error>err); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. await here will imply an unhandled exception if handleFailed throws an exception, is this the intent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was placed when testing, removing it now |
||
} finally { | ||
jobsInProgress.delete(inProgressItem); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 The
@returns
comment still says onlyvoid
is returned.