@@ -36,7 +36,6 @@ module.exports = class Context {
3636 }
3737
3838 startTimeout ( ) {
39- const ms = this . task . timeout || 5000 ;
4039 this . timeout = setTimeout ( ( ) => {
4140 this . cancel ( ) ;
4241 this . done ( { error : 'Job timed out' } ) ;
@@ -47,6 +46,7 @@ module.exports = class Context {
4746 * @param {Function } job - The job function to be executed
4847 */
4948 start ( job ) {
49+ console . log ( new Date ( ) . toISOString ( ) , 'Started Running' , this . task . id , 'date' , this . task . date ) ;
5050 performance . mark ( 'job_start' ) ;
5151 // Defines a timeout for the job
5252 this . startTimeout ( ) ;
@@ -89,6 +89,7 @@ module.exports = class Context {
8989 * @returns {Number } duration - Time elapsed from start to stop in ms
9090 */
9191 stop ( ) {
92+ console . log ( new Date ( ) . toISOString ( ) , 'Stoping' ) ;
9293 this . running = undefined ;
9394 clearTimeout ( this . timeout ) ;
9495 performance . mark ( 'job_stop' ) ;
@@ -102,13 +103,12 @@ module.exports = class Context {
102103 * @param {Number } current - Current state of property like repeat.limit=100
103104 * @returns {Boolean } - rerunable or not
104105 */
105- rerunable ( attr , current ) {
106+ rerunable ( attr , current = 0 ) {
106107 const { task} = this ,
107108 node = task [ attr ] || { } ,
108109 interval = node . interval ,
109110 limit = node . limit || Infinity ,
110111 canRerun = current < limit ;
111-
112112 if ( node && interval && canRerun ) {
113113 return delay ( task . date , interval ) ;
114114 }
@@ -135,12 +135,16 @@ module.exports = class Context {
135135 * @private
136136 * @param {Object | null } err
137137 * @param {Object | null } res
138- * @returns {String } - done, complete, retry, fail
138+ * @returns {String } - done, complete, retry, failed
139139 */
140140 nextStatus ( err , res ) {
141- const success = this . repeatable ( ) ? 'done' : 'complete' ;
142- const fail = this . retryable ( ) ? 'retry' : 'failed' ;
143- return err ? fail : success ;
141+ const success = ( ) => {
142+ return this . repeatable ( ) ? 'done' : 'complete' ;
143+ }
144+ const fail = ( ) => {
145+ return this . retryable ( ) ? 'retry' : 'failed' ;
146+ }
147+ return err ? fail ( ) : success ( ) ;
144148 }
145149
146150 /**
0 commit comments