Skip to content

Commit 62ab944

Browse files
committed
fix: enhance job retrieval logic in Agenda.now method to create job if not found
1 parent d84e24e commit 62ab944

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ export class Agenda extends EventEmitter {
541541
async now<DATA>(name: string, data?: DATA): Promise<Job<DATA | void>> {
542542
log('Agenda.now(%s, [Object])', name);
543543
try {
544-
const job = await this.jobs({ name })[0];
544+
let job = await this.jobs({ name })[0];
545+
if (!job) job = await this.create(name, data);
545546

546547
job.schedule(new Date());
547548
await job.save();

0 commit comments

Comments
 (0)