We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2bd7638 commit e6ea7e2Copy full SHA for e6ea7e2
src/Job.ts
@@ -153,6 +153,11 @@ export class Job<DATA = unknown | void> {
153
// we have no job definition, therfore we are not the job processor, but a client call
154
// so we get the real state from database
155
const dbJob = await this.agenda.db.getJobs({ _id: this.attrs._id });
156
+ if (!dbJob || dbJob.length === 0) {
157
+ // @todo: should we just return false instead? a finished job could have been removed from database,
158
+ // and then this would throw...
159
+ throw new Error(`job with id ${this.attrs._id} not found in database`);
160
+ }
161
this.attrs.lastRunAt = dbJob[0].lastRunAt;
162
this.attrs.lastFinishedAt = dbJob[0].lastFinishedAt;
163
}
0 commit comments