File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export class Queue {
103
103
} ) ,
104
104
priority : options . priority || 0 ,
105
105
active : false ,
106
- timeout : ( options . timeout > 0 ) ? options . timeout : 25000 ,
106
+ timeout : ( options . timeout >= 0 ) ? options . timeout : 25000 ,
107
107
created : new Date ( ) ,
108
108
failed : null
109
109
} ) ;
Original file line number Diff line number Diff line change @@ -2153,4 +2153,35 @@ describe('Models/Queue', function() {
2153
2153
2154
2154
} ) ;
2155
2155
2156
+ /**
2157
+ *
2158
+ * Regression test for issue 15: Indefinite job Timeout is broken
2159
+ *
2160
+ * https://github.com/billmalarky/react-native-queue/issues/15
2161
+ *
2162
+ */
2163
+ it ( 'does not override an explicitly set job timeout value of 0 with the default value of 25000.' , async ( ) => {
2164
+
2165
+ const queue = await QueueFactory ( ) ;
2166
+ queue . flushQueue ( ) ;
2167
+ const jobName = 'job-name' ;
2168
+
2169
+ // Attach the worker.
2170
+ queue . addWorker ( jobName , async ( ) => { } ) ;
2171
+
2172
+ // Create a job
2173
+ queue . createJob ( jobName , { random : 'this is 1st random data' } , {
2174
+ timeout : 0
2175
+ } , false ) ;
2176
+
2177
+ // Check that the created job has a timeout value of 0 instead of 25000.
2178
+ const jobs = await queue . getJobs ( true ) ;
2179
+ const job = jobs [ 0 ] ;
2180
+ job . timeout . should . equal ( 0 ) ;
2181
+
2182
+ // Flush jobs
2183
+ queue . flushQueue ( ) ;
2184
+
2185
+ } ) ;
2186
+
2156
2187
} ) ;
You can’t perform that action at this time.
0 commit comments