@@ -689,7 +689,15 @@ class ProdWorker {
689
689
reconnectionDelayMax : 3000 ,
690
690
} ,
691
691
handlers : {
692
- RESUME_AFTER_DEPENDENCY : async ( { completions } ) => {
692
+ RESUME_AFTER_DEPENDENCY : async ( { attemptId, completions } ) => {
693
+ logger . log ( "Handling RESUME_AFTER_DEPENDENCY" , {
694
+ attemptId,
695
+ completions : completions . map ( ( c ) => ( {
696
+ id : c . id ,
697
+ ok : c . ok ,
698
+ } ) ) ,
699
+ } ) ;
700
+
693
701
if ( ! this . paused ) {
694
702
logger . error ( "Failed to resume after dependency: Worker not paused" ) ;
695
703
return ;
@@ -720,12 +728,48 @@ class ProdWorker {
720
728
return ;
721
729
}
722
730
731
+ const firstCompletion = completions [ 0 ] ;
732
+ if ( ! firstCompletion ) {
733
+ logger . error ( "Failed to resume after dependency: No first completion" , {
734
+ completions,
735
+ waitForTaskReplay : this . waitForTaskReplay ,
736
+ nextResumeAfter : this . nextResumeAfter ,
737
+ } ) ;
738
+ return ;
739
+ }
740
+
723
741
switch ( this . nextResumeAfter ) {
724
742
case "WAIT_FOR_TASK" : {
743
+ if ( this . waitForTaskReplay ) {
744
+ if ( this . waitForTaskReplay . message . friendlyId !== firstCompletion . id ) {
745
+ logger . error ( "Failed to resume after dependency: Task friendlyId mismatch" , {
746
+ completions,
747
+ waitForTaskReplay : this . waitForTaskReplay ,
748
+ } ) ;
749
+ return ;
750
+ }
751
+ } else {
752
+ // Only log here so we don't break any existing behavior
753
+ logger . debug ( "No waitForTaskReplay" , { completions } ) ;
754
+ }
755
+
725
756
this . waitForTaskReplay = undefined ;
726
757
break ;
727
758
}
728
759
case "WAIT_FOR_BATCH" : {
760
+ if ( this . waitForBatchReplay ) {
761
+ if ( ! this . waitForBatchReplay . message . runFriendlyIds . includes ( firstCompletion . id ) ) {
762
+ logger . error ( "Failed to resume after dependency: Batch friendlyId mismatch" , {
763
+ completions,
764
+ waitForBatchReplay : this . waitForBatchReplay ,
765
+ } ) ;
766
+ return ;
767
+ }
768
+ } else {
769
+ // Only log here so we don't break any existing behavior
770
+ logger . debug ( "No waitForBatchReplay" , { completions } ) ;
771
+ }
772
+
729
773
this . waitForBatchReplay = undefined ;
730
774
break ;
731
775
}
0 commit comments