Interface: CompiledWorkerOptions
worker.CompiledWorkerOptions
WorkerOptions where the attributes the Worker requires are required and time units are converted from ms formatted strings to numbers.
Hierarchy
Omit
<WorkerOptionsWithDefaults
,"serverOptions"
>↳
CompiledWorkerOptions
Properties
activities
• Optional
activities: object
Mapping of activity name to implementation
Inherited from
Omit.activities
buildId
• Optional
buildId: string
A string that should be unique to the exact worker code/binary being executed.
This is used to populate the binaryChecksum
attribute in history events originated from this Worker.
Default
@temporalio/worker
package name and version + checksum of workflow bundle's code
Inherited from
Omit.buildId
bundlerOptions
• Optional
bundlerOptions: Object
Type declaration
Name | Type | Description |
---|---|---|
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. |
webpackConfigHook? | (config : Configuration ) => Configuration | Before Workflow code is bundled with Webpack, webpackConfigHook is called with the Webpack configuration object so you can modify it. |
Inherited from
Omit.bundlerOptions
connection
• Optional
connection: NativeConnection
A connected NativeConnection instance.
If not provided, the worker will default to connect insecurely to localhost:7233
.
Inherited from
Omit.connection
dataConverter
• Optional
dataConverter: DataConverter
Provide a custom DataConverter.
Inherited from
Omit.dataConverter
debugMode
• 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
Inherited from
Omit.debugMode
defaultHeartbeatThrottleInterval
• 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
number of milliseconds or ms-formatted string
Default
30 seconds
Inherited from
Omit.defaultHeartbeatThrottleInterval
defaultHeartbeatThrottleIntervalMs
• defaultHeartbeatThrottleIntervalMs: number
enableNonLocalActivities
• enableNonLocalActivities: boolean
Whether or not to poll on the Activity task queue.
If disabled and activities are registered on the Worker, it will run only local Activities.
Default
true
Inherited from
Omit.enableNonLocalActivities
enableSDKTracing
• 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 CoreOptions.telemetryOptions to enable tracing in Core.
Default
false
Inherited from
Omit.enableSDKTracing
identity
• identity: string
A human-readable string that can identify your worker
Default
${process.pid}@${os.hostname()}
Inherited from
Omit.identity
interceptors
• Optional
interceptors: WorkerInterceptors
A mapping of interceptor type to a list of factories or module paths.
By default, ActivityInboundLogInterceptor and WorkflowInboundLogInterceptor are installed. If you wish to customize the interceptors while keeping the defaults, use appendDefaultInterceptors.
When using workflowBundle, these Workflow interceptors (WorkerInterceptors.workflowModules
) are not used.
Instead, provide them via workflowInterceptorModules when calling bundleWorkflowCode.
Inherited from
Omit.interceptors
isolateExecutionTimeout
• isolateExecutionTimeout: string
| number
Time to wait for result when calling a Workflow isolate function.
Format
number of milliseconds or ms-formatted string
This value is not exposed at the moment.
Default
5s
Inherited from
Omit.isolateExecutionTimeout
isolateExecutionTimeoutMs
• isolateExecutionTimeoutMs: number
loadedDataConverter
• loadedDataConverter: LoadedDataConverter
maxActivitiesPerSecond
• Optional
maxActivitiesPerSecond: number
Limits the number of Activities per second that this Worker will process. (Does not limit the number of Local Activities.) The Worker will not poll for new Activities if by doing so it might receive and execute an Activity which would cause it to exceed this limit. Must be a positive number.
If unset, no rate limiting will be applied to Worker's Activities. (tctl task-queue describe
will display the
absence of a limit as 100,000.)
Inherited from
Omit.maxActivitiesPerSecond
maxCachedWorkflows
• 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.
Most users are able to fit at least 250 Workflows per GB of available memory. The major factors contributing to a Workflow's memory weight are the size of allocations made by the Workflow itself and the size of the Workflow bundle (code and source map). For the SDK test Workflows, we managed to fit 750 Workflows per GB.
Default
max(maxHeapMemory / 1GiB - 1, 1) * 250
Inherited from
Omit.maxCachedWorkflows
maxConcurrentActivityTaskExecutions
• maxConcurrentActivityTaskExecutions: number
Maximum number of Activity tasks to execute concurrently. Adjust this to improve Worker resource consumption.
Default
100
Inherited from
Omit.maxConcurrentActivityTaskExecutions
maxConcurrentLocalActivityExecutions
• maxConcurrentLocalActivityExecutions: number
Maximum number of Activity tasks to execute concurrently. Adjust this to improve Worker resource consumption.
Default
100
Inherited from
Omit.maxConcurrentLocalActivityExecutions
maxConcurrentWorkflowTaskExecutions
• maxConcurrentWorkflowTaskExecutions: number
Maximum number of Workflow tasks to execute concurrently. Adjust this to improve Worker resource consumption.
Default
100
Inherited from
Omit.maxConcurrentWorkflowTaskExecutions
maxHeartbeatThrottleInterval
• maxHeartbeatThrottleInterval: string
| number
Longest interval for throttling activity heartbeats
Format
number of milliseconds or ms-formatted string
Default
60 seconds
Inherited from
Omit.maxHeartbeatThrottleInterval
maxHeartbeatThrottleIntervalMs
• maxHeartbeatThrottleIntervalMs: number
maxTaskQueueActivitiesPerSecond
• Optional
maxTaskQueueActivitiesPerSecond: number
Sets the maximum number of activities per second the task queue will dispatch, controlled server-side. Note that this only takes effect upon an activity poll request. If multiple workers on the same queue have different values set, they will thrash with the last poller winning.
If unset, no rate limiting will be applied to the task queue.
Inherited from
Omit.maxTaskQueueActivitiesPerSecond
namespace
• namespace: string
The namespace this worker will connect to
Default
"default"
Inherited from
Omit.namespace
reuseV8Context
• reuseV8Context: boolean
Toggle whether to reuse a single V8 context for the workflow sandbox.
Context reuse significantly decreases the amount of resources taken up by workflows. From running basic stress tests we've observed 2/3 reduction in memory usage and 1/3 to 1/2 in CPU usage with this feature turned on.
This feature is experimental and requires further testing before it can be considered stable or made default.
Introduced in SDK version 1.6.0
Inherited from
Omit.reuseV8Context
showStackTraceSources
• showStackTraceSources: boolean
Whether or not to send the sources in enhanced stack trace query responses
Default
false
Inherited from
Omit.showStackTraceSources
shutdownForceTime
• Optional
shutdownForceTime: string
| number
Time to wait before giving up on graceful shutdown and forcefully terminating the worker.
After this duration, the worker will throw GracefulShutdownPeriodExpiredError and any running activities and workflows will not be cleaned up. It is recommended to exit the process after this error is thrown.
Use this option if you must guarantee that the worker eventually shuts down.
Format
number of milliseconds or ms-formatted string
Inherited from
Omit.shutdownForceTime
shutdownForceTimeMs
• Optional
shutdownForceTimeMs: number
shutdownGraceTime
• shutdownGraceTime: string
| number
Time to wait for pending tasks to drain after shutdown was requested.
In-flight activities will be cancelled after this period and their current attempt will be resolved as failed if
they confirm cancellation (by throwing a CancelledFailure or AbortError
).
Format
number of milliseconds or ms-formatted string
Default
0
Inherited from
Omit.shutdownGraceTime
shutdownGraceTimeMs
• shutdownGraceTimeMs: number
sinks
• Optional
sinks: InjectedSinks
<any
>
Implementation of the Sinks interface, a mapping of name to InjectedSink.
Sinks are a mechanism for exporting data from the Workflow sandbox to the Node.js environment, they are necessary because the Workflow has no way to communicate with the outside World.
Sinks are typically used for exporting logs, metrics and traces out from the Workflow.
Sink functions may not return values to the Workflow in order to prevent breaking determinism.
By default the defaultWorkerLogger sink is installed and is required by WorkflowInboundLogInterceptor.
If you wish to customize the sinks while keeping the defaults, merge yours with defaultSinks.
Inherited from
Omit.sinks
stickyQueueScheduleToStartTimeout
• 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
number of milliseconds or ms-formatted string
Default
10s
Inherited from
Omit.stickyQueueScheduleToStartTimeout
stickyQueueScheduleToStartTimeoutMs
• stickyQueueScheduleToStartTimeoutMs: number
taskQueue
• taskQueue: string
The task queue the worker will pull from
Inherited from
Omit.taskQueue
workflowBundle
• Optional
workflowBundle: WorkflowBundleOption
Use a pre-built bundle for Workflow code. Use bundleWorkflowCode to generate the bundle. The version of
@temporalio/worker
used when calling bundleWorkflowCode
must be the exact same version used when calling
Worker.create
.
This is the recommended way to deploy Workers to production.
See https://docs.temporal.io/typescript/production-deploy#pre-build-code for more information.
When using this option, workflowsPath, bundlerOptions and any Workflow interceptors modules provided in * interceptors are not used. To use workflow interceptors, pass them via workflowInterceptorModules when calling bundleWorkflowCode.
Inherited from
Omit.workflowBundle
workflowThreadPoolSize
• workflowThreadPoolSize: number
Controls the number of Worker threads the Worker should create.
Threads are used to create vms for the isolated Workflow environment.
New Workflows are created on this pool in a round-robin fashion.
This value is not exposed at the moment.
Default
1 for reuseV8Context, otherwise 8
Inherited from
Omit.workflowThreadPoolSize
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 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 create via the workflowBundle option.
See https://docs.temporal.io/typescript/production-deploy#pre-build-code for more information.
Inherited from
Omit.workflowsPath