File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,13 +115,14 @@ export function startWorkflowReaper(
115115 const staleAfterMs = Math . max ( 1 , options . staleAfterMs ?? DEFAULT_STALE_AFTER_MS ) ;
116116
117117 const tick = ( ) : void => {
118- const store = createWorkflowStore ( config ) ;
118+ let store : WorkflowStore | undefined ;
119119 try {
120+ store = createWorkflowStore ( config ) ;
120121 reapStaleWorkflows ( store , staleAfterMs ) ;
121122 } catch ( error ) {
122123 options . onError ?.( error ) ;
123124 } finally {
124- store . close ( ) ;
125+ store ? .close ( ) ;
125126 }
126127 } ;
127128
Original file line number Diff line number Diff line change @@ -764,9 +764,9 @@ export class WorkflowStore {
764764
765765 const reaped : WorkflowRunRecord [ ] = [ ] ;
766766 for ( const row of candidates ) {
767- if ( row . pid !== null && isPidAlive ( row . pid ) ) continue ;
768767 const latest = this . getRun ( row . id ) ;
769768 if ( ! latest || ( latest . status !== "running" && latest . status !== "starting" ) ) continue ;
769+ if ( latest . pid !== undefined && isPidAlive ( latest . pid ) ) continue ;
770770 const failed = this . failRun ( row . id , {
771771 error : latest . status === "starting" ? "workflow worker failed to start" : "worker heartbeat lost" ,
772772 errorKind : "heartbeat" ,
You can’t perform that action at this time.
0 commit comments