@@ -749,6 +749,72 @@ describe("Workflow Requests", () => {
749
749
}
750
750
) ;
751
751
752
+ test (
753
+ "should omit if triggerRouteFunction (with partial parallel step execution) gets can't publish to canceled workflow error" ,
754
+ async ( ) => {
755
+ const workflowRunId = `wfr-${ nanoid ( ) } ` ;
756
+ const context = new WorkflowContext ( {
757
+ qstashClient,
758
+ workflowRunId : workflowRunId ,
759
+ initialPayload : undefined ,
760
+ headers : new Headers ( { } ) as Headers ,
761
+ steps : [
762
+ {
763
+ stepId : 0 ,
764
+ concurrent : 1 ,
765
+ stepName : "init" ,
766
+ stepType : "Initial" ,
767
+ targetStep : 1 ,
768
+ } ,
769
+ {
770
+ stepId : 0 ,
771
+ concurrent : 2 ,
772
+ stepName : "sleeping" ,
773
+ stepType : "SleepFor" ,
774
+ targetStep : 1 ,
775
+ } ,
776
+ ] ,
777
+ url : WORKFLOW_ENDPOINT ,
778
+ } ) ;
779
+
780
+ const debug = new WorkflowLogger ( { logLevel : "INFO" , logOutput : "console" } ) ;
781
+ const spy = spyOn ( debug , "log" ) ;
782
+
783
+ await triggerFirstInvocation ( context , 3 , false , debug ) ;
784
+ expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
785
+
786
+ await workflowClient . cancel ( { ids : [ workflowRunId ] } ) ;
787
+
788
+ const result = await triggerRouteFunction ( {
789
+ onStep : async ( ) => {
790
+ await Promise . all ( [ context . sleep ( "sleeping" , 10 ) , context . sleep ( "sleeping" , 10 ) ] ) ;
791
+ } ,
792
+ onCleanup : async ( ) => {
793
+ throw new Error ( "shouldn't come here." ) ;
794
+ } ,
795
+ onCancel : async ( ) => {
796
+ throw new Error ( "shouldn't come here." ) ;
797
+ } ,
798
+ debug,
799
+ } ) ;
800
+
801
+ expect ( result . isOk ( ) ) . toBeTrue ( ) ;
802
+ // @ts -expect-error value will be set since stepFinish isOk
803
+ expect ( result . value ) . toBe ( "workflow-was-finished" ) ;
804
+
805
+ expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
806
+ expect ( spy ) . toHaveBeenLastCalledWith ( "WARN" , "RESPONSE_WORKFLOW" , {
807
+ message : "tried to append to a cancelled workflow. exiting without publishing." ,
808
+ name : "QstashError" ,
809
+ errorMessage :
810
+ '[{"error":"failed to publish to url: can not append to a a cancelled workflow"}]' ,
811
+ } ) ;
812
+ } ,
813
+ {
814
+ timeout : 10000 ,
815
+ }
816
+ ) ;
817
+
752
818
test (
753
819
"should omit the error if the workflow is created with the same id" ,
754
820
async ( ) => {
0 commit comments