workflow] Don't propagate cancellation from non-cancellable scopes to children (#1429)worker] Don't fail Worker on Activity Task decode failures (port from #1473) (#1477)ci] Enable file-based persistence on dev server for stress tests (#1480)workflow] Fix cancel-before-started abandon activity (#1487)doc] Docs were no longer being built and deployed in CI (#1494)workflow] Process all activation jobs as a single batch (#1488)Experimental support for worker tuning has been added along with an implementation for auto-tuning based on available
resources. WorkerOptions now has a tuner field that can be set to a WorkerTuner. This is composed of SlotSuppliers, of which currently FixedSize and ResourceBased are available. ResourceBased tuners change the number of available slots dynamically based on resource usage. For some examples of initializing the worker tuner, see here.
At some point the SlotSupplier interface will be manually implementable, but only fixed-size and resource-based slot suppliers are currently supported. Custom slot suppliers will appear in the future.
This SDK API is experimental and may change in incompatible ways in the future.
workflow] Unify GRPC::CANCELED and DEADLINE_EXCEEDED in an SDK Timeout exception for Update (#1452)workflow] Expose updateId to update handlers (#1450)workflow] Add upsert memo command (#1321)worker] Don't fail Worker on Activity Task decode failures (#1473)worker] Fix clients being created without prefixed metric meter (#1465)workflow] Don't propagate cancellation from non-cancellable scopes to children (#1466)💥 Support for Node.js 14 and older GLIBC releases has been dropped. As announced previously, TS SDK v1.9 was the last minor release to support Node.js 14.
Going forward, the TypeScript SDK requires:
💥 Support for Node.js 16 will soon be dropped. TS SDK v1.10 will be the last minor release to support Node.js 16. TS SDK v1.11 will require Node 18 or higher.
Node.js 14 officially reached end-of-life on April 30th, 2023, and Node.js 16 reached end-of-life on September 11th, 2023 (see Node.js release schedule). We strongly encourage everyone to take immediate action in updating their deployments to supported versions of Node.js to ensure continued compatibility and receive the latest features and security updates.
[client] Both Connection and NativeConnection now accept an apiKey option, making it easier to connect to Temporal Cloud and other Temporal servers that use bearer token authentication (#1385), as well as HTTP CONNECT Proxy (#1411, thanks to @brendan-myers for his help on getting this started 🙏).
[client] The startdelay Workflow option is no longer experimental (#1379). Thanks @tlafano 🙏.
[core] Core can now be configured to emit duration metrics as either seconds or milliseconds, as well as to include unit suffixes in metric names (#1383).
[worker] Add taskQueue and logSource metadata attributes on all log messages emitted inside the context of a worker. These attributes are there make is easier to diagnose some low level issues, as well as allow implementing fine-grained filtering of messages (eg. show DEBUG level messages for user-code, but only WARN for messages from the worker) (#1391).
[client] Bring gRPC retry options in line with other SDKs (#1368). Thanks to @chronos-tachyon 🙏.
[worker] Unreference timer created in parseWorkflowCode (#1370). Thanks @jhecking 🙏.
On POSIX systems, stdout and stderr are now properly inherited by ephemeral servers (e.g. TestWorkflowEnvironment.createLocal() and TestWorkflowEnvironment.createTimeSkipping()), making it easier to diagnose issues while creating a test environment (#1394).
@grpc/grpc-js has been updated to 1.10.x (#1388). It had previously been pinned to 1.7.3 to avoid multiple bugs and incompatibilities introduced in grpc-js 1.8.0. We have since reviewed these changes and confirmed that there is no longer any reason to refrain form updating that dependency.
bundler: Webpack output is now recorded as a single log entry, and color are disabled if output is not being sent to the console (#1414). Thanks @ikonst 🙏.
MockActivityEnvironment no longer causes initialization of the Runtime (#1401).
[common] Improve error messages for failureConverters (#1373).
[doc] Fix comment on default maxConcurrentActivityTaskPolls value (#1374) Thanks @taonic 🙏.
EVENT_TYPE_WORKFLOW_EXECUTION_UPDATE_REQUESTED event (https://github.com/temporalio/sdk-core/pull/677).worker] Fix prometheus and otel regressions (#1345)devDependencies in some of the SDK packages where file URLs were used instead of version numbers.worker] Update webpack error doc link in worker/bundler.ts (#1344)updateId (#1318)worker] Add a workflow metadata query (#1319)The reuseV8Context worker option is now enabled by default. This major optimization of the Workflow sandboxing runtime significantly reduces RAM and CPU usage, without compromising the safety of the deterministic sandbox. You may still revert to the legacy execution model by adding reuseV8Context: false to your worker options.
Note that support for the legacy, non-reuseV8Context execution model may be removed at some point in the future. Please reach out if you find any issue that requires disabling reuseV8Context.
Support for Node.js 14 and Node.js 16 will soon be dropped. Node.js 14 officially reached end-of-life on April 30th, 2023, and Node.js 16 reached end-of-life on September 11th, 2023 (see Node.js release schedule).
This has since then caused a rippling effect, as more and more libraries in the NPM ecosystem are progressively dropping support for both of those older targets. Given that challenges to maintaining compatibility with these outdated Node.js releases will only continue to grow, it is evident that we will soon need to follow suit in discontinuing support for Node.js 14 and 16 in the Temporal TypeScript SDK.
For those reasons:
We strongly encourage everyone to take immediate action in updating their deployments to supported versions of Node.js to ensure continued compatibility and receive the latest features and security updates.
Introduced Workflow Update APIs, both on Workflow side and Client side (#1277, #1312 and #1320). Kudos to @dandavison 🙏.
⚠️ The Workflow Update feature is currently in pre-release stage. Related APIs are considered experimental and may change in the near future. This feature requires Temporal Server version 1.21 or later, and must be enabled through configuration.
Here are some examples to get started:
// An Update is defined similarly to Query and Signal. The second type parameter (input) is optional
const myUpdate = wf.defineUpdate<string, [string]>('myUpdate');
// A handler is a sync or async function; the optional validator is always sync.
wf.setHandler(myUpdate, handler, { validator });
// `await wfHandle.executeUpdate` to start an update and block until it completes or fails.
// The signature resembles `WorkflowClient.start` in that the arguments are supplied
// in the optional options object
// (as opposed to the variadic signatures of wfHandle.query and wfHandle.signal)
// An error is thrown if the RPC times out (we do not poll for this call)
// or if the validator rejects, or the handler throws ApplicationFailure.
const updateResult = await handle.executeUpdate(myUpdate, { args: ['a'] });
// `startUpdate` to block until Accepted and obtain a handle to the Update. Signature the same as `executeUpdate`.
const updateHandle = await handle.startUpdate(myUpdate, { args: ['a'] });
// Blocking call to fetch result, with polling.
// Validation failures or ApplicationFailure in the handler would throw here.
const updateResult = await updateHandle.result();
This release features a major overhaul of Workflow logging, Activity logging support, and Core log forwarding support.
These changes add up to better DX, notably by promoting clear usage patterns that work out of the box, removing the need to use insufficiently documented features, and removing some requirements that were error-prone and a recurring source of support questions.
Workflow Logging
Calling appendDefaultInterceptors() when registering custom interceptors is no longer required in order for Workflow logger support to work properly. appendDefaultInterceptors() is now deprecated and behave as a no-op in most cases (i.e. except when a custom logger is supplied in order to redirect log emitted by activities) (#1290).
Similarly, calling defaultSink() when registering custom sinks is no longer required for Workflow logging to work properly (#1283). SDK's logger sink is now forcibly injected. Registering a custom logger sink named defaultWorkerLogger is still supported, but discouraged and deprecated.
Attributes from the current Workflow are now automatically included as metadata on every log entries emitted using the Workflow context logger, and some key events of the Workflow's lifecycle are now automatically logged (at DEBUG level for most messages; WARN for failures) (#1290).
WorkflowLogInterceptor has been deprecated (#1290).
Activity Logging
Attributes from the current Activity context are now automatically included as metadata on every log entries emitted using the Activity context logger, and some key events of the Activity's lifecycle are now automatically logged (at DEBUG level for most messages; WARN for failures) (#1284).
Logged Activity attributes can be customized by registering an ActivityOutboundCallsInterceptor that intercepts the getLogAttributes() method (#1284).
ActivityInboundLogInterceptor has been deprecated; registering such an interceptor with a custom logger still works, but will prevent the use of the newly introduced getLogAttributes() interceptor. The same is true about modifying the context logger directly (e.g. context.log = myCustomLogger) (#1284).
Core Logging
Log entries forwarded from Core to TS now retain metadata (#1225).
Reduce the default Core log level to WARN and non Core Rust logs to ERROR (#1270).
💥 BREAKING: Non-local activities may now receive cancellation for schedule-to-close and start-to-close timeouts, without heartbeating. Heartbeating is still required to receive server sent cancellations.
All APIs provided through Context.current() can now be accessed directly from the @temporalio/activity import (#1252). Also, thanks to @SergeiMeza for fixing a related issue that would occur when heartbeat and sleep functions were destructured out of Context.current() (#1249) 🙏.
Instead of this:
import { Context } from `@temporalio/activity`;
// ...
Context.current().sleep('5 minutes');
you can now do:
import { sleep } from `@temporalio/activity`;
// ...
sleep('5 minutes');
ActivityInboundCallsInterceptorFactory has been deprecated. Activity Interceptors should now be instantiated using an ActivityInterceptorsFactory (#1284).
MockActivityEnvironment now accept a list of activity interceptors, and more closely match an actual activity execution (#1284).
Allow specifying gRPC CallCredentials on Client connection. Also, fixed the fact that ConnectionOptions.credentials was completely ignored (#1261).
Client and Connection classes now expose a withAbortSignal() method. This can be used to cancel all ongoing connections started within a function's scope (#1272).
Example:
const ctrl = new AbortController();
setTimeout(() => ctrl.abort(), 10_000);
// 👇 throws if incomplete by the timeout.
await conn.withAbortSignal(ctrl.signal, () => { /* make client or direct grpc calls */);
Add startDelay option to workflow start, execute, and signalWithStart (#1300).
WorkerOptions now exposes a nonStickyToStickyPollRatio property, which controls the proportion of Workflow Task Pollers assigned to polling from Regular Task Queue vs to polling from Sticky Tasks Queues (#1254).
Fixed a bug that could happen if the @temporalio/proto was minimized (#1279).
Prevents a Workflow-only Worker from requesting Eager Activity Execution for activities schedules on the same task queue name (#1326).
Introduced Workflow Update APIs, both on Workflow side and Client side (#1277 and #1312). Kudos to @dandavison 🙏.
⚠️ The Workflow Update feature is currently in Public Preview. Related APIs are considered experimental and may change in the near future. This feature requires Temporal Server version 1.21 or later, and must be enabled through configuration.
Here are some examples to get started:
// An Update is defined similarly to Query and Signal. The second type parameter (input) is optional
const myUpdate = wf.defineUpdate<string, [string]>('myUpdate');
// A handler is a sync or async function; the optional validator is always sync.
wf.setHandler(myUpdate, handler, { validator });
// `await wfHandle.executeUpdate` to start an update and block until it completes or fails.
// The signature resembles `WorkflowClient.start` in that the arguments are supplied
// in the optional options object
// (as opposed to the variadic signatures of wfHandle.query and wfHandle.signal)
// An error is thrown if the RPC times out (we do not poll for this call)
// or if the validator rejects, or the handler throws ApplicationFailure.
const updateResult = await handle.executeUpdate(myUpdate, { args: ['a'] });
// `startUpdate` to block until Accepted and obtain a handle to the Update.
// Signature the same as `executeUpdate`.
const updateHandle = await handle.startUpdate(myUpdate, { args: ['a'] });
// Blocking call to fetch result, with polling.
// Validation failures or ApplicationFailure in the handler would throw here.
const updateResult = await updateHandle.result();
This release feature a major overhaul of Workflow logging, Activity logging support, and Core log forwarding support.
These changes add up to better DX, notably by promoting clear usage patterns that work out of the box, remove the need to use insufficiently documented features, and remove some requirements that were error-prone and recurring source of support questions.
Workflow Logging
Calling appendDefaultInterceptors() when registering custom interceptors is no longer required in order for Workflow logger support to work properly. appendDefaultInterceptors() is now deprecated and behave as a no-op in most cases (i.e. except when a custom logger is supplied in order to redirect log emitted by activities) (#1290).
Similarly, calling defaultSink() when registering custom sinks is no longer required for Workflow logging to work properly (#1283). SDK's logger sink is now forcibly injected. Registering a custom logger sink named defaultWorkerLogger is still supported, but discouraged and deprecated.
Attributes from the current Workflow are now automatically included as metadata on every log entries emited using the Workflow context logger, and some key events of the Workflow's lifecycle are now automatically logged (at DEBUG level for most messages; WARN for failures) (#1290).
WorkflowLogInterceptor has been deprecated (#1290).
Activity Logging
Attributes from the current Activity context are now automatically included as metadata on every log entries emited using the Activity context logger, and some key events of the Activity's lifecycle are now automatically logged (at DEBUG level for most messages; WARN for failures) (#1284).
Logged Activity attributes can be customized by registering an ActivityOutboundCallsInterceptor that intercepts the getLogAttributes() method (#1284).
ActivityInboundLogInterceptor has been deprecated; registering such an interceptor with a custom logger still works, but will prevent the use of the newly introduced getLogAttributes() interceptor. The same is true about modifying the context logger directly (eg. context.log = myCustomLogger) (#1284).
Core Logging
Log entries forwarded from Core to TS now retain metadata (#1225).
Reduce the default Core log level to WARN and non Core Rust logs to ERROR (#1270).
💥 Remote activities may now receive cancellation for schedule-to-close and start-to-close timeouts, without heartbeating. Heartbeating is still required to receive server sent cancellations.
All APIs provided through Context.current() can now be accessed directly from the @temporalio/activity import (#1252). Also, thanks to @SergeiMeza for fixing a related issue that would occur when heartbeat and sleep functions were destructured out of Context.current() (#1249) 🙏.
Instead of this:
import { Context } from `@temporalio/activity`;
// ...
Context.current().sleep('5 minutes');
you can now do:
import { sleep } from `@temporalio/activity`;
// ...
sleep('5 minutes');
ActivityInboundCallsInterceptorFactory has been deprecated. Activity Interceptors should now be instantiated using an ActivityInterceptorsFactory (#1284).
MockActivityEnvironment now accept a list of activity interceptors, and more closely match an actual activity execution (#1284).
Allow specifying gRPC CallCredentials on Client connection. Also, fixed the fact that ConnectionOptions.credentials was completely ignored (#1261).
Client and Connection classes now expose a withAbortSignal() method. This can be used to cancel all ongoing connections started within a function's scope. (#1272)
Example:
const ctrl = new AbortController();
setTimeout(() => ctrl.abort(), 10_000);
// 👇 throws if incomplete by the timeout.
await conn.withAbortSignal(ctrl.signal, () => { /* make client or direct grpc calls */);
Add startDelay to workflow (signal) start options (#1300)
WorkerOptions now expose a nonStickyToStickyPollRatio property, which control the proportion of Workflow Task Pollers assigned to polling from Regular Task Queue vs to polling from Sticky Tasks Queues. (#1254)
Enable reuseV8Context by default (#1310)
Fixed a bug that could happen if the @temporalio/proto was minimized (#1279)
worker] Fix a memory leak introduced in v1.8.5 (#1242)[workflow] Add historySizeInBytes and continueAsNewSuggested to WorkflowInfo (#1223).
Remove experimental flags on the following APIs (#1235):
[workflow] Fix a particular case where isReplaying could be incorrectly false if a query came in right after a cache eviction and there had been a signal in the last workflow task before the cache eviction (#1234). This could notably cause situations where calls to sink functions configured with calledDuringReplay = false would be called more than once for a same code location, as well as situations where patched(...) would return true even though that patch had not been set on the first execution.
[workflow] Make ExternalWorkflowHandle.signal signature match that of BaseWorkflowHandle.signal (#1237). Thanks to @gabrielsantosblanchet and @josiah-roberts 🙏.
[worker] Avoid rxjs error while flushing logs on worker shutdown (#1238).
Upgrade protobufjs dependencies (#1219). Thanks to @alex-dixon 🙏.
[workflow] Fix a particular case where isReplaying would be incorrectly true if a query came in right after a cache eviction (#1211). This could notably cause situations where calls to sink functions not configured with calledDuringReplay = true would not be relayed, as well as situations where patched(...) would return false even though this part of the code was being executed for the first time.
[workflow] Avoid errors in Search Attributes Payload Converter if enumerable properties had been added on Array.prototype (#1209).
[worker] Validate buildId is set when useVersioning is true (#1207).
workflow] Remove accidental import of large protos into workflow library (#1203). This had been causing significant memory usage increases on workflow workers since 1.8.1.core] Fix removal of deprecated patch call adjacent to other patch (#587)client] Throw WorkflowExecutionAlreadyStartedError on signalWithStart (#1199 thanks to @satazor 🙏)worker] Update terser, fixes #759 (#760)ActivityCancellationType (#768):boom: [workflow] Move TaskInfo to WorkflowInfo (#761)
BREAKING CHANGE: There is no longer a taskInfo() export from @temporalio/workflow. taskInfo().* fields have been moved to workflowInfo().
:boom: Update activity and worker exports (#764)
BREAKING CHANGE: If you were importing any of the following errors from @temporalio/activity (unlikely), instead import from @temporalio/common: ValueError, PayloadConverterError, IllegalStateError, WorkflowExecutionAlreadyStartedError, WorkflowNotFoundError
RetryPolicy.maximumAttempts: Number.POSITIVE_INFINITY (#784)worker] Prevent ending a worker span twice. (#786)workflow] List registered queries in error response when a query is not found (#791):boom: [worker] Remove unnecessary ReplayWorkerOptions (#816)
BREAKING CHANGE: While this is technically breaking (if you pass options that are irrelevant to replay like maxActivitiesPerSecond, you'll get a compilation error), we decided it did not warrant a major version bump, as it doesn't affect production code (replay is a testing feature) and is only a type change (is caught at compile type by TS users and doesn't affect JS users).
Warn instead of throwing when getting workflowBundle with workflowsPath and bundlerOptions (#833)
⚠️ NOTE: We now prefer taking workflowBundle over workflowsPath when both are provided, which is the correct behavior and what users should expect.
We also now warn that workflow interceptors are ignored when using workflowBundle.
[workflow] Make breakpoints work inside workflow isolate context (#819)
⚠️ NOTE: Bundles created with bundleWorkflowCode should only be used for calling Worker.create when the exact same version of @temporalio/worker is used. (If you don't pin to exact versions in your package.json, then you should use a lockfile, and both the machine that runs bundleWorkflowCode and Worker.create should run npm ci, not npm install.)
⚠️ DEPRECATION: sourceMap and sourceMapPath are now deprecated. We've inlined source maps, so now this works:
const { code } = await bundleWorkflowCode({ workflowsPath });
const worker = await Worker.create({ workflowBundle: { code }, ...otherOptions });
Avoid using dynamic import in @temporalio/testing (#805)
[worker] Don't start activity poller if no activities registered (#808)
Update proto3-json-serializer to ^1.0.3 (#809)
Add @types/long to client (#735)
[worker] Improve worker default options heuristics (#802)
Use GITHUB_TOKEN in create-project for CI (#721)
:boom: [worker] Add webpack configuration, closes #537 (#815)
This was our most-upvoted feature request! (9 👍's.) See WorkerOptions.bundlerOptions.webpackConfigHook for usage.
BREAKING CHANGE: If you provide both workflowBundle & workflowsPath or both workflowBundle & bundlerOptions to Worker.create, a ValueError will now be thrown. While this is technically breaking, TODO
Add @temporalio/nyc-test-coverage package (#798, thanks to @vkarpov15 🙏)
This package adds code coverage for Istanbul. It's currently in beta: the API may be unstable as we gather feedback on it from users. To try it out, see this code snippet for current usage.
[common] Improve ApplicationFailure arguments; add .create and .fromError (#767)
See ApplicationFailure.create and ApplicationFailure.fromError
Expose additional console methods to workflow context (#831)
console.[error|warn|info|debug] can now be called from Workflow code, in addition to console.log
:boom: Various bug fixes (#873)
BREAKING CHANGE: Makes WorkflowExecutionDescription.historyLength a number. This was a Long before, but shouldn't
have been. If you're currently calling:
(await workflowHandle.describe()).historyLength.toNumber();
then remove the .toNumber() call.
This PR also included:
protobufjs a dev dependency of @temporalio/clientcancelChildWorkflowExecution command:boom: Update Core from e261 to b437 (#865 and #873)
BREAKING CHANGE: This fixes a bug where values (memo, search attributes, and retry policy) were not being passed on to
the next Run during Continue-As-New. Now they are, unless you specify different values when calling
continueAsNew
(temporalio/sdk-core#376). [We believe this is unlikely to break
users code—the code would have to be depending on the absence of these values in Continued-As-New Runs.]
This update also have various fixes and features:
[client] Only require signalArgs in signalWithStart when needed (#847)
:boom: Improvements to @temporalio/testing (#865 and #873)
BREAKING CHANGE: Breaking for the testing package in some of the more advanced and rarely used options:
runInNormalTime when waiting for workflow resultTestWorkflowEnvironmentOptions is completely redone[Given that these were rarely used and the testing package isn't meant for production use, we don't think this change warrants a major version bump.]
TestWorkflowEnvironment.create is deprecated in favor of:
Various minor features (#865)
Connection.healthService and generate testservice and health in proto package[client] Add a high-level meta Client class (#870)
We now recommend using this instead of our other clients:
import { Client } from '@temporalio/client';
const client = new Client(options);
await client.workflow.start();
await client.activity.heartbeat();
await client.activity.complete();
client.workflow is a WorkflowClient.client.activity is an AsyncCompletionClient.client.schedule.* (see the ScheduleClient proposal).Add ActivityOptions.allowEagerDispatch (default true) (#873)
[testing] Use temporal.download for downloading test server (#864)
Add Webpack rule to auto instrument Workflows for code coverage, add augmentWorkerOptions() (#858, thanks to @vkarpov15 🙏)
nyc-test-coverage README (#866)~1.3.1 of @temporalio/* packages to prevent >= 1.4.0 versions from being installed.:boom: Make client gRPC retry more configurable (#879)
BREAKING CHANGE: GrpcRetryOptions.retryableDecider now gets the attempt number as the first argument. This is an advanced/rare option, and the change should be caught at compile time.
Also adds BackoffOptions and defaultGrpcRetryOptions.
NOTE: This feature is experimental and its API may change.
[client] Delete search attributes with empty array values in describe() response (#878)
:warning: This fixes a bug where empty/deleted Custom Search Attributes were returned as [] from workflowHandle.describe(). Such attribute properties will no longer be present in the WorkflowExecutionDescription.searchAttributes object. Note that this behavior is consistent with what you'll see if using a pre-1.4 version of the SDK with Server version 1.18.
Add support for custom failure converters (#887)
Adds DataConverter.failureConverterPath and FailureConverter, which converts from proto Failure instances to JS Errors and back.
We recommended going with the default (i.e. not using the failureConverterPath option) in order to maintain cross-language Failure serialization compatibility.
NOTE: This feature is experimental and its API may change.
[workflow] Add workflowInfo().unsafe.now() (#882)
It returns the current system time in milliseconds. The safe version of time is new Date() and Date.now(), which are set on the first invocation of a Workflow Task and stay constant for the duration of the Task and during replay.
Upgrade core, add support for OTEL metric temporality (#891)
Remove internal-* packages (#881)
:warning: Any imports from @temporalio/internal-* need to be updated. As noted in their named and READMEs, they're not meant to be used to directly, so we don't imagine this is a common case. However, if you do find instances, they should be changed to importing from:
@temporalio/internal-non-workflow-common ➡️ @temporalio/common/lib/internal-non-workflow
@temporalio/internal-workflow-common ➡️ @temporalio/common
[common] Deprecate internal functions that should have never been exported (#893)
Some time-related and binary conversion internal helper functions were exported from @temporalio/common. They are now deprecated and hidden from the API reference, as they're meant for internal use only.
[workflow] Export LoggerSinks from @temporalio/workflow (#889)
[client] Add max retry interval for client (#883)
Label grpc-retry API as experimental (#891)
Make the failure-converter code symmetric (#891)