File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 11import { MutationError , ErrorCodeEnum } from './MutationError' ;
22import { getBullConnection } from './getBullConnection' ;
33import { Options } from '../definitions' ;
4+ import { resolve } from 'dns' ;
45
56export async function deleteQueue (
67 prefix : string ,
@@ -20,18 +21,26 @@ export async function deleteQueue(
2021 }
2122 }
2223
23- //redis-cli: scan 0 match fullName* count 300
24- const stream = connection . scanStream ( { match : fullName + '*' , count : 300 } ) ;
24+ const total = await new Promise < number > ( ( resolve , reject ) => {
25+ //redis-cli: scan 0 match fullName* count 300
26+ const stream = connection . scanStream ( { match : fullName + '*' , count : 300 } ) ;
2527
26- let total = 0 ;
28+ let total = 0 ;
2729
28- stream . on ( 'data' , async ( keys ) => {
29- for ( let i = 0 ; i < keys . length ; i ++ ) {
30- const del = await connection . del ( keys [ i ] ) ;
31- if ( del ) {
32- total ++ ;
30+ stream . on ( 'data' , async ( keys ) => {
31+ for ( let i = 0 ; i < keys . length ; i ++ ) {
32+ const del = await connection . del ( keys [ i ] ) ;
33+ if ( del ) {
34+ total ++ ;
35+ }
3336 }
34- }
37+ } ) ;
38+
39+ stream . on ( 'end' , ( ) => {
40+ resolve ( total ) ;
41+ } ) ;
42+
43+ stream . on ( 'error' , reject ) ;
3544 } ) ;
3645
3746 return total ;
You can’t perform that action at this time.
0 commit comments