Skip to main content

Interface: WorkerOptions

worker.WorkerOptions

Options to configure the Worker

Properties

activities

Optional activities: ActivityInterface

Mapping of activity name to implementation.


bundlerOptions

Optional bundlerOptions: Object

Type declaration

NameTypeDescription
ignoreModules?string[]List of modules to be excluded from the Workflows bundle. Use this option when your Workflow code references an import that cannot be used in isolation, e.g. a Node.js built-in module. Modules listed here MUST not be used at runtime. > NOTE: This is an advanced option that should be used with care.

connection

Optional connection: NativeConnection

A connected NativeConnection instance.

If not provided, the worker will default to connect insecurely to localhost:7233.


dataConverter

Optional dataConverter: DataConverter

Provide a custom DataConverter.


debugMode

Optional debugMode: boolean

If true Worker runs Workflows in the same thread allowing debugger to attach to Workflow instances.

Workflow execution time will not be limited by the Worker in debugMode.

default false


defaultHeartbeatThrottleInterval

Optional defaultHeartbeatThrottleInterval: string | number

Default interval for throttling activity heartbeats in case ActivityOptions.heartbeat_timeout is unset. When the timeout is set in the ActivityOptions, throttling is set to heartbeat_timeout * 0.8.

format ms formatted string

default 30 seconds


enableSDKTracing

Optional enableSDKTracing: boolean

Enable opentelemetry tracing of SDK internals like polling, processing and completing tasks.

Useful for debugging issues with the SDK itself.

For completeness the Rust Core also generates opentelemetry spans which connect to the Worker's spans. Configure {@link CoreOptions.telemetryOptions} to enable tracing in Core.

default false


interceptors

Optional interceptors: WorkerInterceptors

A mapping of interceptor type to a list of factories or module paths


maxCachedWorkflows

Optional maxCachedWorkflows: number

The number of Workflow isolates to keep in cached in memory

Cached Workflows continue execution from their last stopping point. If the Worker is asked to run an uncached Workflow, it will need to replay the entire Workflow history. Use as a dial for trading memory for CPU time.

You should be able to fit about 500 Workflows per GB of memory dependening on your Workflow bundle size. For the SDK test Workflows, we managed to fit 750 Workflows per GB.

This number is impacted by the the Worker's {@link maxIsolateMemoryMB} option.

default max(os.totalmem() / 1GiB - 1, 1) * 200


maxConcurrentActivityTaskExecutions

Optional maxConcurrentActivityTaskExecutions: number

Maximum number of Activity tasks to execute concurrently. Adjust this to improve Worker resource consumption.

default 100


maxConcurrentActivityTaskPolls

Optional maxConcurrentActivityTaskPolls: number

Maximum number of concurrent poll Activity task requests to perform at a time. Higher values will result in higher throughput and load on the Worker. If your Worker is overloaded, tasks might start timing out in which case, reduce this value.

default 5


maxConcurrentWorkflowTaskExecutions

Optional maxConcurrentWorkflowTaskExecutions: number

Maximum number of Workflow tasks to execute concurrently. Adjust this to improve Worker resource consumption.

default 100


maxConcurrentWorkflowTaskPolls

Optional maxConcurrentWorkflowTaskPolls: number

Maximum number of concurrent poll Workflow task requests to perform at a time. Higher values will result in higher throughput and load on the Worker. If your Worker is overloaded, tasks might start timing out in which case, reduce this value.

default 5


maxHeartbeatThrottleInterval

Optional maxHeartbeatThrottleInterval: string | number

Longest interval for throttling activity heartbeats

format ms formatted string

default 60 seconds


namespace

Optional namespace: string

The namespace this worker will connect to

default "default"


nonStickyToStickyPollRatio

Optional nonStickyToStickyPollRatio: number

maxConcurrentWorkflowTaskPolls * this number = the number of max pollers that will be allowed for the nonsticky queue when sticky tasks are enabled. If both defaults are used, the sticky queue will allow 4 max pollers while the nonsticky queue will allow one. The minimum for either poller is 1, so if max_concurrent_wft_polls is 1 and sticky queues are enabled, there will be 2 concurrent polls.

default 0.2


shutdownGraceTime

Optional shutdownGraceTime: string | number

Time to wait for pending tasks to drain after shutdown was requested.

format ms formatted string or number of milliseconds

default 5s


sinks

Optional sinks: InjectedSinks<any>


stickyQueueScheduleToStartTimeout

Optional stickyQueueScheduleToStartTimeout: string

How long a workflow task is allowed to sit on the sticky queue before it is timed out and moved to the non-sticky queue where it may be picked up by any worker.

format ms formatted string

default 10s


taskQueue

taskQueue: string

The task queue the worker will pull from


workflowBundle

Optional workflowBundle: WorkflowBundle

Use a pre-built bundle for Workflow code. Use bundleWorkflowCode to genrate a bundle.

This is the recommended way to deploy Workers to production.

See https://docs.temporal.io/typescript/production-deploy#pre-build-code for more information.


workflowsPath

Optional workflowsPath: string

Path to look up workflows in, any function exported in this path will be registered as a Workflows in this Worker.

If this option is provided to Worker.create, Webpack compliation will be triggered.

This option is typically used for local development, for production it's preferred to pre-build the Workflow bundle and pass that to Worker.create via the workflowBundle option.

See https://docs.temporal.io/typescript/production-deploy#pre-build-code for more information.