Skip to content

Commit

Permalink
fix(job): deserialize priority in fromJSON (#3126)
Browse files Browse the repository at this point in the history
  • Loading branch information
devhyper authored Mar 8, 2025
1 parent 707853c commit c3269b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/classes/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ export class Job<

job.delay = parseInt(json.delay);

job.priority = parseInt(json.priority);

job.timestamp = parseInt(json.timestamp);

if (json.finishedOn) {
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/job-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface JobJsonRaw {
attemptsMade?: string;
finishedOn?: string;
processedOn?: string;
priority: string;
timestamp: string;
failedReason: string;
stacktrace: string[];
Expand Down
7 changes: 6 additions & 1 deletion tests/test_job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,12 @@ describe('Job', function () {

const worker = new Worker(
queueName,
async () => {
async (job: Job) => {
if (job.name === 'test1') {
expect(job.priority).to.be.eql(8);
} else {
expect(job.priority).to.be.eql(1);
}
await delay(20);
},
{ connection, prefix },
Expand Down

0 comments on commit c3269b1

Please sign in to comment.