Skip to content

Commit be4c026

Browse files
committed
fix(job): ensure agenda is ready before calling save job
1 parent 7d69680 commit be4c026

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Job.ts

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ export class Job<DATA = any | void> {
170170
}
171171

172172
async save(): Promise<Job> {
173+
// ensure db connection is ready
174+
await this.agenda.ready;
173175
return this.agenda.db.saveJob(this);
174176
}
175177

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class Agenda extends EventEmitter {
6363

6464
private jobProcessor?: JobProcessor;
6565

66-
private ready: Promise<void>;
66+
readonly ready: Promise<void>;
6767

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

0 commit comments

Comments
 (0)