Skip to content

Commit e685596

Browse files
committed
some type checks
1 parent 8ed8093 commit e685596

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/RedisTaskQueue.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,19 @@ class RedisTaskQueue {
6363
async getStatus(jobId) {
6464
if (!jobId) return;
6565
const activeJobs = await this.list();
66-
const isActive = activeJobs.find((j) => {
67-
return JSON.parse(j).id === jobId;
68-
});
69-
if (isActive) return "active";
66+
if (activeJobs && Array.isArray(activeJobs)) {
67+
const isActive = activeJobs.find((j) => {
68+
return JSON.parse(j).id === jobId;
69+
});
70+
if (isActive) return "active";
71+
}
7072
const buriedJobs = await this.listBuried();
71-
const isBuried = buriedJobs.find((j) => {
72-
return JSON.parse(j).id === jobId;
73-
});
74-
if (isBuried) return "buried";
73+
if (buriedJobs && Array.isArray(buriedJobs)) {
74+
const isBuried = buriedJobs.find((j) => {
75+
return JSON.parse(j).id === jobId;
76+
});
77+
if (isBuried) return "buried";
78+
}
7579
return "completed";
7680
}
7781
}

0 commit comments

Comments
 (0)