Skip to content

Commit

Permalink
fix(job): ensure agenda is ready before calling save job
Browse files Browse the repository at this point in the history
  • Loading branch information
simllll committed Oct 20, 2020
1 parent 7d69680 commit be4c026
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export class Job<DATA = any | void> {
}

async save(): Promise<Job> {
// ensure db connection is ready
await this.agenda.ready;
return this.agenda.db.saveJob(this);
}

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Agenda extends EventEmitter {

private jobProcessor?: JobProcessor;

private ready: Promise<void>;
readonly ready: Promise<void>;

async getRunningStats(fullDetails = false): Promise<IAgendaStatus> {
if (!this.jobProcessor) {
Expand Down

0 comments on commit be4c026

Please sign in to comment.