File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -700,7 +700,14 @@ export class WorkflowClient extends BaseClient {
700
700
} ;
701
701
try {
702
702
return ( await this . workflowService . signalWithStartWorkflowExecution ( req ) ) . runId ;
703
- } catch ( err ) {
703
+ } catch ( err : any ) {
704
+ if ( err . code === grpcStatus . ALREADY_EXISTS ) {
705
+ throw new WorkflowExecutionAlreadyStartedError (
706
+ 'Workflow execution already started' ,
707
+ options . workflowId ,
708
+ workflowType
709
+ ) ;
710
+ }
704
711
this . rethrowGrpcError ( err , 'Failed to signalWithStart Workflow' , { workflowId : options . workflowId } ) ;
705
712
}
706
713
}
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import {
30
30
TimeoutType ,
31
31
WorkflowExecution ,
32
32
WorkflowExecutionAlreadyStartedError ,
33
+ WorkflowIdReusePolicy ,
33
34
WorkflowNotFoundError ,
34
35
} from '@temporalio/common' ;
35
36
import { msToNumber , tsToMs } from '@temporalio/common/lib/time' ;
@@ -1138,6 +1139,28 @@ export function runIntegrationTests(codec?: PayloadCodec): void {
1138
1139
}
1139
1140
} ) ;
1140
1141
1142
+ test ( 'WorkflowClient.signalWithStart fails with WorkflowExecutionAlreadyStartedError' , async ( t ) => {
1143
+ const { client } = t . context ;
1144
+ const workflowId = uuid4 ( ) ;
1145
+ await client . execute ( workflows . sleeper , {
1146
+ taskQueue : 'test' ,
1147
+ workflowId,
1148
+ } ) ;
1149
+ await t . throwsAsync (
1150
+ client . signalWithStart ( workflows . sleeper , {
1151
+ taskQueue : 'test' ,
1152
+ workflowId,
1153
+ signal : workflows . interruptSignal ,
1154
+ signalArgs : [ 'interrupted from signalWithStart' ] ,
1155
+ workflowIdReusePolicy : WorkflowIdReusePolicy . WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE ,
1156
+ } ) ,
1157
+ {
1158
+ instanceOf : WorkflowExecutionAlreadyStartedError ,
1159
+ message : 'Workflow execution already started' ,
1160
+ }
1161
+ ) ;
1162
+ } ) ;
1163
+
1141
1164
test ( 'Handle from WorkflowClient.start follows only own execution chain' , async ( t ) => {
1142
1165
const { client } = t . context ;
1143
1166
const workflowId = uuid4 ( ) ;
You can’t perform that action at this time.
0 commit comments