This repository was archived by the owner on Mar 9, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -459,7 +459,12 @@ class Queue extends Emitter {
459
459
this . toKey ( 'jobs' ) ,
460
460
this . toKey ( 'delayed' ) ,
461
461
jobId
462
- ) . then ( ( ) => this ) ;
462
+ ) . then ( ( ) => {
463
+ if ( this . settings . storeJobs ) {
464
+ this . jobs . delete ( jobId ) ;
465
+ }
466
+ return this ;
467
+ } ) ;
463
468
464
469
if ( cb ) helpers . asCallback ( promise , cb ) ;
465
470
return promise ;
Original file line number Diff line number Diff line change @@ -658,6 +658,32 @@ describe('Queue', (it) => {
658
658
t . is ( jobData , job . toData ( ) ) ;
659
659
} ) ;
660
660
661
+ it . describe ( 'Remove' , ( it ) => {
662
+ it ( 'should remove a job' , async ( t ) => {
663
+ const queue = t . context . makeQueue ( {
664
+ getEvents : false ,
665
+ } ) ;
666
+
667
+ const [ job1 , job2 ] = await Promise . all ( [
668
+ queue . createJob ( ) . save ( ) ,
669
+ queue . createJob ( ) . save ( ) ,
670
+ ] ) ;
671
+ const [ ref1 , ref2 ] = await Promise . all ( [
672
+ queue . getJob ( job1 . id ) ,
673
+ queue . getJob ( job2 . id ) ,
674
+ ] ) ;
675
+ t . is ( ref1 , job1 ) ;
676
+ t . is ( ref2 , job2 ) ;
677
+
678
+ await Promise . all ( [ queue . removeJob ( job1 . id ) , job2 . remove ( ) ] ) ;
679
+
680
+ t . deepEqual (
681
+ await Promise . all ( [ queue . getJob ( job1 . id ) , queue . getJob ( job2 . id ) ] ) ,
682
+ [ null , null ]
683
+ ) ;
684
+ } ) ;
685
+ } ) ;
686
+
661
687
it . describe ( 'Health Check' , ( it ) => {
662
688
it ( 'reports a waiting job' , async ( t ) => {
663
689
const queue = t . context . makeQueue ( {
You can’t perform that action at this time.
0 commit comments