new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Temporal · Develop · all subjects

message-passing

194 notes in this subject, read out of this brain and free to use. This is page 4 of 4.

Dynamic Signal and Query definition in TypeScript

For flexible use cases with dynamic Signals (such as a generated ID), you have two approaches: 1) Avoid making it dynamic by collapsing all Signals into one handler and move the ID to the payload using a 'fat handler' solution. 2) Actually make the Signal name dynamic by inlining the Signal definition per handler. Example inline: `wf.setHandler(wf.defineSignal(`task-${taskAId}`), (payload) => { /* do task A things */ });`.

Query error when no Worker polling Task Queue

When sending a Query and there is no Workflow Worker polling the Task Queue, you receive a `client.ServiceError` with `cause.code` attribute set to gRPC status code 9 `FAILED_PRECONDITION`.

Query error on handler failure

When a Query handler fails, you receive a `client.QueryNotRegisteredError` exception. Any error in a Query handler will trigger this error, which differs from Signal and Update requests where errors can lead to Workflow Task Failure instead.

Update error when validator rejects

When sending an Update and the Update is rejected by an Update validator, you receive a `client.WorkflowUpdateFailedError` exception. Update validators can reject Updates before they are written to History.

Update error on handler failure

When an Update fails after being accepted, you receive a `client.WorkflowUpdateFailedError` exception. Update failures are like Workflow failures. Issues that cause a Workflow failure in the main method also cause Update failures in the Update handler, including a failed Child Workflow, a failed Activity (if Activity retries are set to a finite number), or the Workflow author raising `ApplicationFailure`.

Update error when Workflow finishes during handler execution

When the Workflow finishes while an Update handler execution is in progress, you receive a `client.ServiceError` with `cause.code` attribute set to gRPC status code 5 `NOT_FOUND`. This can happen if the Workflow was canceled or failed, or if the Workflow completed normally or continued-as-new and the Workflow author did not wait for handlers to be finished.

Update error on Workflow Task failure before acceptance

When a handler causes a Workflow Task to fail and the Update request hasn't been accepted by the server, you receive a `client.ServiceError` with `cause.code` attribute set to gRPC status code 9 `FAILED_PRECONDITION` after some retries.

Update error on Workflow Task failure after acceptance

When a handler causes a Workflow Task to fail and the Update request has already been accepted, the Update is durable. Once the Workflow is healthy again after a code deploy, use a `WorkflowUpdateHandle` to fetch the Update result.

Update error when no Workers polling Task Queue

When sending an Update and no Workflow Workers are polling the Task Queue, the SDK Client will retry your request indefinitely.

Get Update handle by Update ID in TypeScript

Use `WorkflowHandle.getUpdateHandle()` to fetch a handle for an in-progress Update using the Update ID. This allows you to retrieve results for an Update that is already in progress.

Use workflow.currentUpdateInfo to access Update metadata

Use `workflow.currentUpdateInfo()` to obtain information about the current Update. This includes the Update ID, which can be useful for deduplication when using Continue-As-New.

Signal handler options in TypeScript

`setHandler` can take `SignalHandlerOptions` such as `description` and `unfinishedPolicy` as described in the API reference docs for `workflow.setHandler()`.

Query handler options in TypeScript

`setHandler` can take `QueryHandlerOptions` such as `description` as described in the API reference docs for `workflow.setHandler()`.

Update handler options in TypeScript

`setHandler` can take `UpdateHandlerOptions` such as `validator`, `description` and `unfinishedPolicy` as described in the API reference docs for `workflow.setHandler()`.

Give your agent this brain