Skip to content

Commit

Permalink
fix(scripts): use command name in error message when moving to finished
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Mar 22, 2024
1 parent ea973b9 commit ec37637
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/classes/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Job<
: undefined;

this.toKey = queue.toKey.bind(queue);
this.scripts = new Scripts(queue);
this.setScripts();

this.queueQualifiedName = queue.qualifiedName;
}
Expand Down Expand Up @@ -349,6 +349,10 @@ export class Job<
return job;
}

protected setScripts() {
this.scripts = new Scripts(this.queue);
}

private static optsFromJSON(rawOpts?: string): JobsOptions {
const opts = JSON.parse(rawOpts || '{}');

Expand Down Expand Up @@ -687,7 +691,7 @@ export class Job<
delay,
);
(<any>multi).moveToDelayed(args);
command = 'delayed';
command = 'moveToDelayed';
} else {
// Retry immediately
(<any>multi).retryJob(
Expand All @@ -710,7 +714,7 @@ export class Job<
);
(<any>multi).moveToFinished(args);
finishedOn = args[this.scripts.moveToFinishedKeys.length + 1] as number;
command = 'failed';
command = 'moveToFinished';
}

const results = await multi.exec();
Expand Down
6 changes: 5 additions & 1 deletion src/classes/queue-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class QueueBase extends EventEmitter implements MinimalQueue {
this.qualifiedName = queueKeys.getQueueQualifiedName(name);
this.keys = queueKeys.getKeys(name);
this.toKey = (type: string) => queueKeys.toKey(name, type);
this.scripts = new Scripts(this);
this.setScripts();
}

/**
Expand All @@ -81,6 +81,10 @@ export class QueueBase extends EventEmitter implements MinimalQueue {
return this.connection.client;
}

protected setScripts() {
this.scripts = new Scripts(this);
}

/**
* Returns the version of the Redis instance the client is connected to,
*/
Expand Down

0 comments on commit ec37637

Please sign in to comment.