Workflows in Temporal may be replayed from the beginning of their history when resumed. In order for Temporal to recreate the exact state Workflow code was in, the code is required to be fully deterministic. To prevent breaking determinism, in the Node SDK, Workflow code runs in an isolated execution environment limited to functionality provided by the SDK.
External Dependencies is an isolation breaking mechanism that allows injecting replay-aware functions from the main NodeJS environment into a Workflow isolate. They are typically used in order to inject custom instrumentation (e.g. logger) functions into the isolate.
The following configuration options are for controlling how an injected function is executed.
A boolean controling whether or not the injected function will be called during Workflow replay - defaults to
The different modes for an injected function to be applied to the isolate are documented in the API reference.
IGNORED apply modes are safe to use since they cannot break determinism.
Use other modes only if you're certain you know what you're doing.
Functions configured to use
ASYNC* apply modes always copy their arguments and return value, which limits them to primitive types such as
Function configured to use
SYNC* apply modes always copy their return value and can control whether to copy their arguments or pass them in using isolated-vm References.
Define the interface for your external dependencies
Call an external dependency function from a Workflow
Inject a function as a Workflow external dependency