Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,12 @@ class Queue extends Emitter {
this.toKey('jobs'),
this.toKey('delayed'),
jobId
).then(() => this);
).then(() => {
if (this.settings.storeJobs) {
this.jobs.delete(jobId);
}
return this;
});

if (cb) helpers.asCallback(promise, cb);
return promise;
Expand Down
26 changes: 26 additions & 0 deletions test/queue-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,32 @@ describe('Queue', (it) => {
t.is(jobData, job.toData());
});

it.describe('Remove', (it) => {
it('should remove a job', async (t) => {
const queue = t.context.makeQueue({
getEvents: false,
});

const [job1, job2] = await Promise.all([
queue.createJob().save(),
queue.createJob().save(),
]);
const [ref1, ref2] = await Promise.all([
queue.getJob(job1.id),
queue.getJob(job2.id),
]);
t.is(ref1, job1);
t.is(ref2, job2);

await Promise.all([queue.removeJob(job1.id), job2.remove()]);

t.deepEqual(
await Promise.all([queue.getJob(job1.id), queue.getJob(job2.id)]),
[null, null]
);
});
});

it.describe('Health Check', (it) => {
it('reports a waiting job', async (t) => {
const queue = t.context.makeQueue({
Expand Down