@@ -93,6 +93,7 @@ import {
9393} from './base-client' ;
9494import { mapAsyncIterable } from './iterators-utils' ;
9595import { WorkflowUpdateStage , encodeWorkflowUpdateStage } from './workflow-update-stage' ;
96+ import { InternalWorkflowStartOptionsSymbol , InternalWorkflowStartOptions } from './internal' ;
9697
9798const UpdateWorkflowExecutionLifecycleStage = temporal . api . enums . v1 . UpdateWorkflowExecutionLifecycleStage ;
9899
@@ -1248,8 +1249,13 @@ export class WorkflowClient extends BaseClient {
12481249 protected async _startWorkflowHandler ( input : WorkflowStartInput ) : Promise < string > {
12491250 const req = await this . createStartWorkflowRequest ( input ) ;
12501251 const { options : opts , workflowType } = input ;
1252+ const internalOptions = ( opts as InternalWorkflowStartOptions ) [ InternalWorkflowStartOptionsSymbol ] ;
12511253 try {
1252- return ( await this . workflowService . startWorkflowExecution ( req ) ) . runId ;
1254+ const response = await this . workflowService . startWorkflowExecution ( req ) ;
1255+ if ( internalOptions != null ) {
1256+ internalOptions . backLink = response . link ?? undefined ;
1257+ }
1258+ return response . runId ;
12531259 } catch ( err : any ) {
12541260 if ( err . code === grpcStatus . ALREADY_EXISTS ) {
12551261 throw new WorkflowExecutionAlreadyStartedError (
@@ -1265,10 +1271,12 @@ export class WorkflowClient extends BaseClient {
12651271 protected async createStartWorkflowRequest ( input : WorkflowStartInput ) : Promise < StartWorkflowExecutionRequest > {
12661272 const { options : opts , workflowType, headers } = input ;
12671273 const { identity, namespace } = this . options ;
1274+ const internalOptions = ( opts as InternalWorkflowStartOptions ) [ InternalWorkflowStartOptionsSymbol ] ;
1275+
12681276 return {
12691277 namespace,
12701278 identity,
1271- requestId : uuid4 ( ) ,
1279+ requestId : internalOptions ?. requestId ?? uuid4 ( ) ,
12721280 workflowId : opts . workflowId ,
12731281 workflowIdReusePolicy : encodeWorkflowIdReusePolicy ( opts . workflowIdReusePolicy ) ,
12741282 workflowIdConflictPolicy : encodeWorkflowIdConflictPolicy ( opts . workflowIdConflictPolicy ) ,
@@ -1295,6 +1303,7 @@ export class WorkflowClient extends BaseClient {
12951303 userMetadata : await encodeUserMetadata ( this . dataConverter , opts . staticSummary , opts . staticDetails ) ,
12961304 priority : opts . priority ? compilePriority ( opts . priority ) : undefined ,
12971305 versioningOverride : opts . versioningOverride ?? undefined ,
1306+ ...filterNullAndUndefined ( internalOptions ?? { } ) ,
12981307 } ;
12991308 }
13001309
0 commit comments