@@ -585,7 +585,15 @@ class ProdWorker {
585
585
reconnectionDelayMax : 3000 ,
586
586
} ,
587
587
handlers : {
588
- RESUME_AFTER_DEPENDENCY : async ( { completions } ) => {
588
+ RESUME_AFTER_DEPENDENCY : async ( { attemptId, completions } ) => {
589
+ logger . log ( "Handling RESUME_AFTER_DEPENDENCY" , {
590
+ attemptId,
591
+ completions : completions . map ( ( c ) => ( {
592
+ id : c . id ,
593
+ ok : c . ok ,
594
+ } ) ) ,
595
+ } ) ;
596
+
589
597
if ( ! this . paused ) {
590
598
logger . error ( "Failed to resume after dependency: Worker not paused" ) ;
591
599
return ;
@@ -616,12 +624,48 @@ class ProdWorker {
616
624
return ;
617
625
}
618
626
627
+ const firstCompletion = completions [ 0 ] ;
628
+ if ( ! firstCompletion ) {
629
+ logger . error ( "Failed to resume after dependency: No first completion" , {
630
+ completions,
631
+ waitForTaskReplay : this . waitForTaskReplay ,
632
+ nextResumeAfter : this . nextResumeAfter ,
633
+ } ) ;
634
+ return ;
635
+ }
636
+
619
637
switch ( this . nextResumeAfter ) {
620
638
case "WAIT_FOR_TASK" : {
639
+ if ( this . waitForTaskReplay ) {
640
+ if ( this . waitForTaskReplay . message . friendlyId !== firstCompletion . id ) {
641
+ logger . error ( "Failed to resume after dependency: Task friendlyId mismatch" , {
642
+ completions,
643
+ waitForTaskReplay : this . waitForTaskReplay ,
644
+ } ) ;
645
+ return ;
646
+ }
647
+ } else {
648
+ // Only log here so we don't break any existing behavior
649
+ logger . debug ( "No waitForTaskReplay" , { completions } ) ;
650
+ }
651
+
621
652
this . waitForTaskReplay = undefined ;
622
653
break ;
623
654
}
624
655
case "WAIT_FOR_BATCH" : {
656
+ if ( this . waitForBatchReplay ) {
657
+ if ( ! this . waitForBatchReplay . message . runFriendlyIds . includes ( firstCompletion . id ) ) {
658
+ logger . error ( "Failed to resume after dependency: Batch friendlyId mismatch" , {
659
+ completions,
660
+ waitForBatchReplay : this . waitForBatchReplay ,
661
+ } ) ;
662
+ return ;
663
+ }
664
+ } else {
665
+ // Only log here so we don't break any existing behavior
666
+ logger . debug ( "No waitForBatchReplay" , { completions } ) ;
667
+ }
668
+
625
669
this . waitForBatchReplay = undefined ;
626
670
break ;
627
671
}
0 commit comments