npm @temporalio/client 1.5.0

latest releases: 1.13.0, 1.12.3, 1.12.2...
2 years ago

Features

  • [client] The experimental WorkflowHandle.fetchHistory function can now be used to easily obtain a single
    Workflow execution's history (#974).

  • [client] Introduced (experimental) high level API to list workflows (#942,
    #974):

    for await (const workflowInfo of client.workflow.list({ query: 'WorkflowType="MySuperCoolWorkflow"' })) {
      console.log(`${workflowInfo.workflowId} ${workflowInfo.runId}`);
    }

    The same API can also be used to efficiently obtain a list of workflows histories. Multiple histories are fetched from
    the server in parallel (up to concurrency, defaults to 5), which may improve performances.

    for await (const { workflowId, history } of client.workflow.list().intoHistories({ concurrency: 10 })) {
      // ...
    }
  • [client] Added (experimental) high level API to work with Schedules (#937,
    #960):

    // Define a schedule that will start workflow 'RefreshClientTableWorkflow` every day at 5 AM and 1 PM
    await client.schedule.create({
      scheduleId: `refresh-client-table-every-morning`,
      spec: {
        calendars: [{ hour: [5, 13] }],
      },
      action: {
        type: 'startWorkflow',
        workflowType: 'RefreshClientTableWorkflow',
        taskQueue,
      },
    });

    Note that Schedules requires Temporal version 1.18 or later.

  • [core] Core's (experimental) telemetry options are now more configurable (#963,
    #977). Notably, filters can now be specified independently
    for logging (applicable to both console and forward loggers) and tracing. Function makeTelemetryFilterString
    can be used to easily build filter strings. Also, OTel metrics export interval can now be modified (defaults to 1
    second).

    Note: the TelemetryOptions interface has changed quite a bit. Using appropriate new options is highly recommended.
    Backward compatibility for legacy options is provided, to the extent possible, but these legacy options have been
    deprecated.

  • [client] WorkflowClient now supports a simpler way to define interceptors (#956).
    Interceptors should now be provided as an array of interceptor object, rather than an array of factory to those
    objects under a field named calls. Former definition syntax is still supported, though deprecated.

    BEFORE

      interceptors: {
        calls: [
          (workflowId) => {
            create(...) => { ... }
          }
        ]
      }

    AFTER

      interceptors: [
        {
          create(...) => { ... }
        }
      ]
  • [worker] Introduced an experimental API to efficiently replay a large number of workflow histories. Teams may
    notably use this API to validate that changes to their workflow code will not cause non-determinism errors on existing
    workflow instances, before rolling out these changes to production (#920,
    #974).

    EXAMPLE USAGE

    const histories = client.workflow.list({ query: 'WorkflowType="MyWorkflow"' }).intoHistories({ concurrency: 10 });
    const replayResults = await Worker.runReplayHistories(
      {
        workflowsPath: require.resolve('./workflows'),
        // ...
      },
      histories
    );
    console.log(`Found ${replayResults.errors.length} replay errors`);
  • Added activity_task_received metric (#439)

Bug Fixes

  • [workflow] Don't fail workflow task if a query handler was not found (#932).

  • [worker] Wait for worker shutdown if runUntil promise throws (#943).
    Previously, Worker.runUntil would not wait for worker to complete its shutdown if the inner fnOrPromise threw an
    error. Now, it will always wait for both worker shutdown AND the inner fnOrPromise to resolve. If either one throw
    an error, then that error is rethrown. If both throw an error, a CombinedWorkerRunError will be thrown instead,
    with a cause attribute containing both errors.

  • The (experimental) FailureConverter type now receives its PayloadConverter through an argument on convertion
    methods, rather than through an option supplied at construction time (#936).
    This provides a more predictable behaviour in the common case of using the default failure converter. More over,
    FailureConverter.errorToFailure function's return type has been lossen, so that it supports greater customization on
    user side (#927)

  • [client] ConnectionOptions.connectTimeout is now being applied correctly (#954).

  • [workflow] Properly encode memos in makeContinueAsNewFunc (#955).
    They were previously not encoded at all, resulting in a failure due to invalid data.

  • [worker] Activity metric scheduled_to_start_latency now reports the time from the schedule time of the
    current attempt to the start time of that same attempt, instead of the time elapsed since the initial schedule time
    (#975). This new definition aligns with other SDKs and is
    more useful from a monitoring perspective.

  • [workflow] Previously, condition(fn, 0) was incorrectly handled the same as condition(fn), meaning that the
    function would block indefinitely and would return nothing once fn evaluated to true. It now behaves the same as
    condition(fn, 1), ie. the function will sleep for a very short time, then return true if fn evaluates to true,
    or false if timeout reaches its expiration (#985).

  • [core] Fixed some non-deterministic behaviour in workflows containing local activities, due to heartbeats
    being incorrectly counted as logical workflow tasks (#987).

  • [core] core-bridge has been refactored so that it does not retain static references to custom TypeScript error
    constructors (#983). This change is part of an ongoing effort
    to resolve multiple issues observed by some users in execution of their unit tests based on sdk-typescript, notably in
    conjunction with Jest, Mocha and Vitest.

  • [worker] The default log function now write errors using process.stderr.write rather than console.error
    (#940). This avoids complains by some test runners.

  • [debugger] Log errors comming from VS Code debugger (#968)

  • Bug Fixes in Core SDK:

    • Fixed a situation causing Core to send activations containing both a legacy query and other jobs (#427)
    • Don't use a process-wide unique id for sticky queues (#430)
    • Added support for ignorable history events (#422)
    • Avoid hang in duplicated run-ids during replay (#417)
    • Backoff more if we receive ResourceExhausted error (#408)

Miscellaneous Tasks

  • Improved code linting (#771, thanks to @JounQin 🙏)
  • [client] Extract a BaseClient super class (#957)

Don't miss a new client release

NewReleases is sending notifications on new releases.