@@ -86,6 +86,8 @@ export interface WorkerOptions {
86
86
* {@link WorkerOptions.useVersioning}. It will also populate the `binaryChecksum` field
87
87
* on older servers.
88
88
*
89
+ * ℹ️ Required if {@link useVersioning} is `true`.
90
+ *
89
91
* @default `@temporalio/worker` package name and version + checksum of workflow bundle's code
90
92
*
91
93
* @experimental
@@ -636,7 +638,16 @@ export function appendDefaultInterceptors(
636
638
}
637
639
638
640
export function addDefaultWorkerOptions ( options : WorkerOptions ) : WorkerOptionsWithDefaults {
639
- const { maxCachedWorkflows, showStackTraceSources, namespace, reuseV8Context, sinks, ...rest } = options ;
641
+ const {
642
+ buildId,
643
+ useVersioning,
644
+ maxCachedWorkflows,
645
+ showStackTraceSources,
646
+ namespace,
647
+ reuseV8Context,
648
+ sinks,
649
+ ...rest
650
+ } = options ;
640
651
const debugMode = options . debugMode || isSet ( process . env . TEMPORAL_DEBUG ) ;
641
652
const maxConcurrentWorkflowTaskExecutions = options . maxConcurrentWorkflowTaskExecutions ?? 40 ;
642
653
const maxConcurrentActivityTaskExecutions = options . maxConcurrentActivityTaskExecutions ?? 100 ;
@@ -646,10 +657,15 @@ export function addDefaultWorkerOptions(options: WorkerOptions): WorkerOptionsWi
646
657
? Math . max ( Math . floor ( ( Math . max ( heapSizeMiB - 200 , 0 ) * 600 ) / 1024 ) , 10 )
647
658
: Math . max ( Math . floor ( ( Math . max ( heapSizeMiB - 400 , 0 ) * 250 ) / 1024 ) , 10 ) ;
648
659
660
+ if ( useVersioning && ! buildId ) {
661
+ throw new TypeError ( 'Must provide a buildId if useVersioning is true' ) ;
662
+ }
663
+
649
664
return {
650
665
namespace : namespace ?? 'default' ,
651
666
identity : `${ process . pid } @${ os . hostname ( ) } ` ,
652
- useVersioning : options . useVersioning ?? false ,
667
+ useVersioning : useVersioning ?? false ,
668
+ buildId,
653
669
shutdownGraceTime : 0 ,
654
670
maxConcurrentLocalActivityExecutions : 100 ,
655
671
enableNonLocalActivities : true ,
0 commit comments