npm @temporalio/testing 1.12.0-rc.0

latest releases: 1.13.0, 1.12.3, 1.12.2...
3 months ago

[1.12.0.rc0] - 2025-05-30

Note Worthy Features

  • Add experimental support for Worker Deployment Versioning (#1679)

  • Add support for Typed Search Attributes. (#1612, #1625)

    TypedSearchAttributes are intended to replace the existing (not type-enforced) SearchAttributes.

    // Define a typed search attribute; that would generally be done at the top of one's
    // `workflow.ts` file, or in some shared location, similar to definition of Signals,
    // Query and Update types
    const orderStatusSearchAttribute = defineSearchAttributeKey('orderStatus', 'KEYWORD');
    
  • Add ability to register new Search Attributes when starting a local development server (#1624)

    // Starting a new local development server, immediately registering the specified search attributes.
    const env = await createLocalTestEnvironment({
      server: {
        searchAttributes: [orderStatusSearchAttribute],
      },
    });
    
  • Add support for the Update-with-Start API on the Workflow Client. (#1585).

    Example usage

    const startWorkflowOperation = WithStartWorkflowOperation.create(transactionWorkflow, {
      workflowId,
      args: [transactionID],
      taskQueue: 'early-return',
      workflowIdConflictPolicy: 'FAIL',
    });
    
    // This is the result of the _update_ call
    const earlyConfirmation = await client.workflow.executeUpdateWithStart(getTransactionConfirmation, {
      startWorkflowOperation,
    });
    
    // This is an handle to the workflow execution that was started. It can be used
    // to wait for the workflow execution to complete and capture its return value
    const workflowHandle = await startWorkflowOperation.workflowHandle();
    const finalReport = await workflowHandle.result();
    
  • Add support for default activity handler, update handler and query handler. A default handler will be called for any incoming request if no handler has been explicitely set for the given type name. (#1639, #1640, #1642)

    Example usage: Default Update Handler

    export async function myWorkflow(useDefinedQuery: boolean): Promise<void> {
      setDefaultUpdateHandler((updateName, ...args: any[]) => {
        // ...
      });
    

    Example usage: Default Query Handler

    export async function myWorkflow(useDefinedQuery: boolean): Promise<void> {
      setDefaultQueryHandler((queryName: string, ...args: any[]) => {
        // ...
      });
    
  • Add experimental support for emitting custom metrics from workflows and activities. (#1705)

Example usage: From a Workflow

import * as wf from `@temporalio/workflow`;

async function myWorkflow() {
  const myHistogramMetric = wf.metricMeter.createHistogram(
    'my-custom-histogram',
    'int', // or 'float'
    'ms', // Units (optional)
    'description' // (optional)
  );

  myHistogramMetric.record(50);
  myHistogramMetric.record(50, { tag1: 'tag-value' });
}

Example usage: From an Activity

import * as act from `@temporalio/activity`

const myCounterMetric = metricMeter.createCounter('activity-counter');

async function myActivity() {
  const myCounterMetric.add(1);
}
  • Add experimental support for more powerful configuration of Workflow Task Pollers and Activity Task Pollers. (#1704)

  • Add experimental support for task priority. For now, only the numeric priority value is supported, which is a number between 1 (top priority) and 5 (lowest priority). Priority can be set when starting workflows or scheduling activities. Note that this feature requires server side support which has not yet been released. (#1669)

Minor features

  • Add a new category property on ApplicationFailure. (#1719)

    This new option allows controlling some of the observability and logging behaviors of the Worker related to a failure thrown from an Activity.

  • Add high level API support for the CountWorkflowExecution operation to the Workflow Client (#1573)
    That operation efficiently determine the number of Workflows matching some list filter; the list filter may also include a GROUP BY clause.

    Example usage

    const workflowCount = await client.workflow.count(`TaskQueue = '${taskQueue}' GROUP BY ExecutionStatus`);

    after which workflowCount might look something like this:

    {
      count: 5,
      groups: [
        { count: 2, groupValues: [['Running']] },
        { count: 3, groupValues: [['Completed']] },
      ],
    };
  • [workflow] Expose AbortController to the worker sandbox (#1576, thanks @lukeramsden).

  • The following APIs are no longer @experimental: (#1590, #1622)

    • Workflow Update
    • Client gRPC Retry interceptor
    • HTTP Proxy support
    • Forwarding and filtering of Core's logs
    • Configuration of Core's metrics
    • WorkerOptions.nonStickyToStickyPollRatio
  • [interceptors-opentelemetry] Propagate the OpenTelemetry tracing context from a workflow to local activities (#1577)

  • [interceptors-opentelemetry] Add error messages to OpenTelemetry tracing span status, when applicable. (#1632, thanks @xavierroma)

  • [workflow] Include information about the current Update (if applicable) in Workflow logging output (#1595)

  • [worker] Add multiple Worker and Telemetry options (#1623)

    • On TelemetryOptions:

      • Add the following properties:
        • metrics.metricPrefix
        • metrics.attachServiceName
        • metrics.globalTags
        • metrics.histogramBucketOverrides
        • metrics.otel.http
      • Move metrics.temporality to metrics.otel.temporality, as Core doesn't support that option on Prometheus. This is coherent with other Core-based SDKs.
      • Deprecate property TelemetryOption.noTemporalPrefixForMetrics, promoting the use of the more versatile metrics.metricPrefix property instead
    • On DevServerConfig:

      • Add server.uiPort property — fixes #1611
      • Fix the server.dbFilename property, which had never worked due to a naming inconsistency between the lang's interface and bridge's code
    • On NativeConnectionOptions:

      • Add boolean property disableErrorCodeMetricTags.

    All of those change preserve compatibility with prior behaviors and deprecated settings.

  • Add partial support for powering a Workflow Client from a NativeConnection rather than a Connection. (#1699)

  • Expose root execution information from WorkflowInfo and WorkflowDescription. (#1662)

Bug Fixes

  • [workflow] Fix multiple context leaks and bugs in reuseV8Context executor. (#1605)

    • …by reassigning a new object to an existing shared global variable;
    • …by modifying one of Node's built in global objects;
    • …by deleting a previously set global variable;
    • …by defining global symbol properties.

    💣 These changes should

  • [client] Homogenize and clarify that default address is localhost everywhere in public exposed code (that's the correct thing to do and should be non-breaking everywhere except on very badly configured dual-stack machines, in which case they would have had errors anyway due to inconsistencies between Client and NativeClient).

  • [workflow] Clearly differentiate Workflow Task Failures resulting from unhandle Promise rejections (#1606).

    This was a recurring source of extremely difficult to diagnose Workflow Task failures. Going forward, a Workflow Task Failure resulting form unhandled Promise rejection will clearly indicate "Unhandled promise rejection".

  • [workflow] Do not appear to support conflict policy when start a child workflow (#1649)

  • 💥 Use plain Error in FailureConverter, WorkflowFailedError, and WorkflowUpdateFailedError (#1685)

  • [client] Properly set temporal-namespace header on gRPC requests (#1712)

  • [bridge] The Core Bridge layer is now much more robust, better handle various unexpected situations, and provide more detailed and more consistent error messages. (#1698)

    The Core Bridge layer went through a major refactor to prepare it for upcoming new features. This refactor also allowed resolution of several lifecycle bugs that could happen in various edge cases, including:

    • Node discards Promises created by calling into the Core Bridge with callbacks (#1302)
    • Process hangs on normal exit if some native resource (NativeConnection, Worker, WorkflowTestEnvironment, etc) were not properly closed (#1413).
    • Failure to start ephemeral server prevents shutdown of the process (#1443).
    • Hundreds of OTLP errors showing up in logs when shutting down the runtime (#1495).

    💥 This refactor establishes a much stronger distinction between public and internal APIs. Though we never encouraged direct import from the @temporalio/core-bridge package, some types were previously exported from the core-bridge package and reexported from a public facing package. Due to that confusion, it is possible that some users may have been previously importing types from that package. This is no longer possible and will result in compilation errors. Please import those types from the @temporalio/worker or @temporalio/testing packages.

  • [bridge] Log forwarding from Core SDK to the TS logger is now less demanding on CPU. As part of the COre Bridge Layer refactor, log forwarding was changed to a push model, rather than a pull model; which was previously reported to cause a constant, non negligeable CPU usage, even when the Worker was left idle for long periods of time. (#1698)

Miscellaneous Tasks

Thanks

Huge thanks to the following users for their contributions.

Advanced notices

  • 1.12.x will likely be the last minor release to support Node 18.

Don't miss a new testing release

NewReleases is sending notifications on new releases.