Commit 50a87fc 1 parent 4ef1cbc commit 50a87fc Copy full SHA for 50a87fc
File tree 4 files changed +466
-413
lines changed
4 files changed +466
-413
lines changed Original file line number Diff line number Diff line change 18
18
19
19
strategy :
20
20
matrix :
21
- node-version : [12 ]
21
+ node-version : [14 ]
22
22
23
23
steps :
24
24
- uses : actions/checkout@v2
Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ export class Worker<T = any> extends QueueBase {
85
85
this . on ( 'error' , err => console . error ( err ) ) ;
86
86
}
87
87
88
+ async waitUntilReady ( ) {
89
+ await super . waitUntilReady ( ) ;
90
+ return this . blockingConnection . client ;
91
+ }
92
+
88
93
get repeat ( ) {
89
94
return new Promise < Repeat > ( async resolve => {
90
95
if ( ! this . _repeat ) {
@@ -99,7 +104,7 @@ export class Worker<T = any> extends QueueBase {
99
104
}
100
105
101
106
private async run ( ) {
102
- const client = await this . client ;
107
+ const client = await this . blockingConnection . client ;
103
108
104
109
if ( this . closing ) {
105
110
return ;
Original file line number Diff line number Diff line change @@ -930,6 +930,57 @@ describe('workers', function() {
930
930
await queueScheduler . close ( ) ;
931
931
} ) ;
932
932
933
+ it ( 'continue processing after a worker has stalled' , async function ( ) {
934
+ let first = true ;
935
+ this . timeout ( 10000 ) ;
936
+
937
+ const worker = new Worker (
938
+ queueName ,
939
+ async job => {
940
+ if ( first ) {
941
+ first = false ;
942
+ return delay ( 2000 ) ;
943
+ }
944
+ } ,
945
+ {
946
+ lockDuration : 1000 ,
947
+ lockRenewTime : 3000 , // The lock will not be updated
948
+ } ,
949
+ ) ;
950
+ await worker . waitUntilReady ( ) ;
951
+
952
+ const queueScheduler = new QueueScheduler ( queueName , {
953
+ stalledInterval : 100 ,
954
+ } ) ;
955
+ await queueScheduler . waitUntilReady ( ) ;
956
+
957
+ const job = await queue . add ( 'test' , { bar : 'baz' } ) ;
958
+
959
+ const completed = new Promise ( resolve => {
960
+ worker . on ( 'completed' , resolve ) ;
961
+ } ) ;
962
+
963
+ await completed ;
964
+
965
+ await worker . close ( ) ;
966
+ await queueScheduler . close ( ) ;
967
+ } ) ;
968
+
969
+ it ( 'stalled interval cannot be zero' , function ( done ) {
970
+ this . timeout ( 10000 ) ;
971
+ let queueScheduler ;
972
+
973
+ try {
974
+ queueScheduler = new QueueScheduler ( queueName , {
975
+ stalledInterval : 0 ,
976
+ } ) ;
977
+ // Fail test if we reach here.
978
+ done ( new Error ( 'Should throw an exception' ) ) ;
979
+ } catch ( err ) {
980
+ done ( ) ;
981
+ }
982
+ } ) ;
983
+
933
984
describe ( 'Concurrency process' , ( ) => {
934
985
it ( 'should run job in sequence if I specify a concurrency of 1' , async ( ) => {
935
986
let processing = false ;
You can’t perform that action at this time.
0 commit comments