@@ -59,7 +59,7 @@ async function _json(req, res) {
5959 const words = state . split ( '-' ) ;
6060 const finalStateName = words . map ( ( word ) => _ . capitalize ( word ) ) . join ( '' ) ;
6161 jobs = await queue [ `get${ finalStateName } ` ] ( 0 , 1000 ) ;
62- jobs = jobs . map ( ( j ) => j . toJSON ( ) ) ;
62+ jobs = jobs . map ( ( j ) => j && j . toJSON ( ) ) ;
6363 }
6464
6565 const filename = `${ queueName } -${ state } -dump.json` ;
@@ -125,13 +125,21 @@ async function _html(req, res) {
125125 jobs = await queue . getJobs ( stateTypes , startId , endId , order === 'asc' ) ;
126126 }
127127
128- for ( const job of jobs ) {
129- const jobState = queue . IS_BEE ? job . status : await job . getState ( ) ;
130- job . showRetryButton = ! queue . IS_BEE || jobState === 'failed' ;
131- job . retryButtonText = jobState === 'failed' ? 'Retry' : 'Trigger' ;
132- job . showPromoteButton = ! queue . IS_BEE && jobState === 'delayed' ;
133- job . showDeleteRepeatableButton = queue . IS_BULL && job . opts . repeat ;
134- job . parent = JobHelpers . getKeyProperties ( job . parentKey ) ;
128+ for ( let i = 0 ; i < jobs . length ; i ++ ) {
129+ if ( ! jobs [ i ] ) {
130+ jobs [ i ] = {
131+ showRetryButton : false ,
132+ showPromoteButton : false ,
133+ showDeleteRepeatableButton : false ,
134+ } ;
135+ } else {
136+ const jobState = queue . IS_BEE ? jobs [ i ] . status : await jobs [ i ] . getState ( ) ;
137+ jobs [ i ] . showRetryButton = ! queue . IS_BEE || jobState === 'failed' ;
138+ jobs [ i ] . retryButtonText = jobState === 'failed' ? 'Retry' : 'Trigger' ;
139+ jobs [ i ] . showPromoteButton = ! queue . IS_BEE && jobState === 'delayed' ;
140+ jobs [ i ] . showDeleteRepeatableButton = queue . IS_BULL && jobs [ i ] . opts . repeat ;
141+ jobs [ i ] . parent = JobHelpers . getKeyProperties ( jobs [ i ] . parentKey ) ;
142+ }
135143 }
136144
137145 let pages = _ . range ( page - 6 , page + 7 ) . filter ( ( page ) => page >= 1 ) ;
0 commit comments