File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed 
internal-packages/run-engine/src/engine Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ export function isCheckpointable(status: TaskRunExecutionStatus): boolean {
3131  return  checkpointableStatuses . includes ( status ) ; 
3232} 
3333
34+ export  function  isFinishedOrPendingFinished ( status : TaskRunExecutionStatus ) : boolean  { 
35+   const  finishedStatuses : TaskRunExecutionStatus [ ]  =  [ "FINISHED" ,  "PENDING_CANCEL" ] ; 
36+   return  finishedStatuses . includes ( status ) ; 
37+ } 
38+ 
3439export  function  isFinalRunStatus ( status : TaskRunStatus ) : boolean  { 
3540  const  finalStatuses : TaskRunStatus [ ]  =  [ 
3641    "CANCELED" , 
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010}  from  "@trigger.dev/database" ; 
1111import  {  nanoid  }  from  "nanoid" ; 
1212import  {  sendNotificationToWorker  }  from  "../eventBus.js" ; 
13- import  {  isExecuting  }  from  "../statuses.js" ; 
13+ import  {  isExecuting ,   isFinishedOrPendingFinished  }  from  "../statuses.js" ; 
1414import  {  EnqueueSystem  }  from  "./enqueueSystem.js" ; 
1515import  {  ExecutionSnapshotSystem ,  getLatestExecutionSnapshot  }  from  "./executionSnapshotSystem.js" ; 
1616import  {  SystemResources  }  from  "./systems.js" ; 
@@ -512,6 +512,14 @@ export class WaitpointSystem {
512512    await  this . $ . runLock . lock ( [ runId ] ,  5000 ,  async  ( )  =>  { 
513513      const  snapshot  =  await  getLatestExecutionSnapshot ( this . $ . prisma ,  runId ) ; 
514514
515+       if  ( isFinishedOrPendingFinished ( snapshot . executionStatus ) )  { 
516+         this . $ . logger . debug ( `#continueRunIfUnblocked: run is finished, skipping` ,  { 
517+           runId, 
518+           snapshot, 
519+         } ) ; 
520+         return ; 
521+       } 
522+ 
515523      //run is still executing, send a message to the worker 
516524      if  ( isExecuting ( snapshot . executionStatus ) )  { 
517525        const  result  =  await  this . $ . runQueue . reacquireConcurrency ( 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments