@@ -33,7 +33,6 @@ import {
33
33
optionalTsToMs ,
34
34
SearchAttributes ,
35
35
tsToMs ,
36
- ValueError ,
37
36
} from '@temporalio/internal-workflow-common' ;
38
37
import { coresdk , temporal } from '@temporalio/proto' ;
39
38
import { DeterminismViolationError , SinkCall , WorkflowInfo } from '@temporalio/workflow' ;
@@ -64,7 +63,7 @@ import pkg from './pkg';
64
63
import { History , Runtime } from './runtime' ;
65
64
import { closeableGroupBy , mapWithState , mergeMapWithState } from './rxutils' ;
66
65
import { childSpan , getTracer , instrument } from './tracing' ;
67
- import { byteArrayToBuffer , convertToParentWorkflowType , toMB } from './utils' ;
66
+ import { byteArrayToBuffer , convertToParentWorkflowType } from './utils' ;
68
67
import {
69
68
addDefaultWorkerOptions ,
70
69
CompiledWorkerOptions ,
@@ -535,13 +534,29 @@ export class Worker {
535
534
compiledOptions : CompiledWorkerOptions ,
536
535
logger : Logger
537
536
) : Promise < WorkflowBundleWithSourceMapAndFilename | undefined > {
538
- if ( compiledOptions . workflowsPath ) {
539
- if ( compiledOptions . workflowBundle ) {
540
- throw new ValueError (
541
- 'You cannot set both WorkerOptions.workflowsPath and .workflowBundle: only one can be used'
537
+ if ( compiledOptions . workflowBundle ) {
538
+ if ( compiledOptions . workflowsPath ) {
539
+ logger . warn ( 'Ignoring WorkerOptions.workflowsPath because WorkerOptions.workflowBundle is set' ) ;
540
+ }
541
+ if ( compiledOptions . bundlerOptions ) {
542
+ logger . warn ( 'Ignoring WorkerOptions.bundlerOptions because WorkerOptions.workflowBundle is set' ) ;
543
+ }
544
+ if ( compiledOptions . interceptors ?. workflowModules ) {
545
+ logger . warn (
546
+ 'Ignoring WorkerOptions.interceptors.workflowModules because WorkerOptions.workflowBundle is set.\n' +
547
+ 'To use workflow interceptors with a workflowBundle, pass them in the call to bundleWorkflowCode.'
542
548
) ;
543
549
}
544
550
551
+ if ( isCodeBundleOption ( compiledOptions . workflowBundle ) ) {
552
+ return parseWorkflowCode ( compiledOptions . workflowBundle . code ) ;
553
+ } else if ( isPathBundleOption ( compiledOptions . workflowBundle ) ) {
554
+ const code = await fs . readFile ( compiledOptions . workflowBundle . codePath , 'utf8' ) ;
555
+ return parseWorkflowCode ( code , compiledOptions . workflowBundle . codePath ) ;
556
+ } else {
557
+ throw new TypeError ( 'Invalid WorkflowOptions.workflowBundle' ) ;
558
+ }
559
+ } else if ( compiledOptions . workflowsPath ) {
545
560
const bundler = new WorkflowCodeBundler ( {
546
561
logger,
547
562
workflowsPath : compiledOptions . workflowsPath ,
@@ -551,21 +566,7 @@ export class Worker {
551
566
webpackConfigHook : compiledOptions . bundlerOptions ?. webpackConfigHook ,
552
567
} ) ;
553
568
const bundle = await bundler . createBundle ( ) ;
554
- logger . info ( 'Workflow bundle created' , { size : `${ toMB ( bundle . code . length ) } MB` } ) ;
555
569
return parseWorkflowCode ( bundle . code ) ;
556
- } else if ( compiledOptions . workflowBundle ) {
557
- if ( compiledOptions . bundlerOptions ) {
558
- throw new ValueError ( 'You cannot set both WorkerOptions.workflowBundle and .bundlerOptions' ) ;
559
- }
560
-
561
- if ( isCodeBundleOption ( compiledOptions . workflowBundle ) ) {
562
- return parseWorkflowCode ( compiledOptions . workflowBundle . code ) ;
563
- } else if ( isPathBundleOption ( compiledOptions . workflowBundle ) ) {
564
- const code = await fs . readFile ( compiledOptions . workflowBundle . codePath , 'utf8' ) ;
565
- return parseWorkflowCode ( code , compiledOptions . workflowBundle . codePath ) ;
566
- } else {
567
- throw new TypeError ( 'Invalid WorkflowOptions.workflowBundle' ) ;
568
- }
569
570
} else {
570
571
return undefined ;
571
572
}
0 commit comments