Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a4b5ef4
docs: environmental configuration
lennessyy Oct 16, 2025
1f49578
docs: light changes
lennessyy Oct 22, 2025
5545bb0
docs: reformat
lennessyy Oct 22, 2025
a266293
remove sdk specific sections
lennessyy Oct 22, 2025
d5c0906
docs: add code formatting
lennessyy Oct 22, 2025
90df9d3
update api instructions
lennessyy Oct 23, 2025
5ddc3ef
docs: consolidate mTLS
lennessyy Oct 23, 2025
1b11a88
docs: add closing tab
lennessyy Oct 23, 2025
d17c96e
docs: fix broken links
lennessyy Oct 23, 2025
d2a5fa9
Merge branch 'main' into env-config
lennessyy Oct 23, 2025
208090f
tighten up
lennessyy Oct 23, 2025
441d31a
docs: line highlight
lennessyy Oct 23, 2025
8a0308a
docs: add dotnet and ruby to envconfig page
lennessyy Oct 27, 2025
067c64f
docs: add ruby and dotnet
lennessyy Nov 3, 2025
2f1ef48
Merge branch 'main' into env-config
lennessyy Nov 3, 2025
f923c45
docs: fix indentation issue
lennessyy Nov 3, 2025
cfc7e9d
Merge branch 'env-config' of https://github.com/temporalio/documentat…
lennessyy Nov 3, 2025
2adbcd6
docs: add dotnet and ruby client pages; fix broken links:
lennessyy Nov 4, 2025
42fb262
Merge branch 'main' into env-config
lennessyy Nov 4, 2025
a4c0393
docs: add config page to sidebar
lennessyy Nov 4, 2025
dbd2111
Merge branch 'env-config' of https://github.com/temporalio/documentat…
lennessyy Nov 4, 2025
0b1ecb8
docs: fix small issues
lennessyy Nov 5, 2025
8790a25
docs: fix broken anchor
lennessyy Nov 5, 2025
07f3c5b
docs: add language highlighing for bash and toml
lennessyy Nov 5, 2025
d05c67f
separate reference to a different page
lennessyy Nov 5, 2025
6b8c6a0
docs: add to sidebar
lennessyy Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 111 additions & 57 deletions docs/develop/dotnet/index.mdx

Large diffs are not rendered by default.

492 changes: 422 additions & 70 deletions docs/develop/dotnet/temporal-client.mdx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/develop/dotnet/temporal-nexus.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: nexus
title: Temporal Nexus - .NET SDK Feature Guide
sidebar_label: Temporal Nexus
description: Use Temporal Nexus within the .NET SDK to connect Durable Executions within and across Namespaces using a Nexus Endpoint, a Nexus Service contract, and Nexus Operations.
description: use Temporal Nexus within the .NET SDK to connect Durable Executions within and across Namespaces using a Nexus Endpoint, a Nexus Service contract, and Nexus Operations.
toc_max_heading_level: 4
keywords:
- temporal
Expand Down
627 changes: 406 additions & 221 deletions docs/develop/environment-configuration.mdx

Large diffs are not rendered by default.

583 changes: 436 additions & 147 deletions docs/develop/go/temporal-client.mdx

Large diffs are not rendered by default.

166 changes: 110 additions & 56 deletions docs/develop/ruby/index.mdx

Large diffs are not rendered by default.

422 changes: 364 additions & 58 deletions docs/develop/ruby/temporal-client.mdx

Large diffs are not rendered by default.

89 changes: 52 additions & 37 deletions docs/develop/typescript/cancellation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,67 @@ tags:
- Workflows
- TypeScript SDK
- Temporal SDKs
description: Explore the power of Cancellation Scopes in TypeScript to manage nested, non-cancellable, and timeout-based operations within Temporal Workflows with ease.
description:
Explore the power of Cancellation Scopes in TypeScript to manage nested, non-cancellable, and timeout-based operations
within Temporal Workflows with ease.
---

## Cancellation scopes in Typescript {#cancellation-scopes}

In the TypeScript SDK, Workflows are represented internally by a tree of cancellation scopes, each with cancellation behaviors you can specify.
By default, everything runs in the "root" scope.
In the TypeScript SDK, Workflows are represented internally by a tree of cancellation scopes, each with cancellation
behaviors you can specify. By default, everything runs in the "root" scope.

Scopes are created using the [CancellationScope](https://typescript.temporal.io/api/classes/workflow.CancellationScope) constructor or one of three static helpers:
Scopes are created using the [CancellationScope](https://typescript.temporal.io/api/classes/workflow.CancellationScope)
constructor or one of three static helpers:

- [cancellable(fn)](https://typescript.temporal.io/api/classes/workflow.CancellationScope#cancellable-1): Children are automatically cancelled when their containing scope is cancelled.
- [cancellable(fn)](https://typescript.temporal.io/api/classes/workflow.CancellationScope#cancellable-1): Children are
automatically cancelled when their containing scope is cancelled.
- Equivalent to `new CancellationScope().run(fn)`.
- [nonCancellable(fn)](https://typescript.temporal.io/api/classes/workflow.CancellationScope#noncancellable): Cancellation does not propagate to children.
- [nonCancellable(fn)](https://typescript.temporal.io/api/classes/workflow.CancellationScope#noncancellable):
Cancellation does not propagate to children.
- Equivalent to `new CancellationScope({ cancellable: false }).run(fn)`.
- [withTimeout(timeoutMs, fn)](https://typescript.temporal.io/api/classes/workflow.CancellationScope#withtimeout): If a timeout triggers before `fn` resolves, the scope is cancelled, triggering cancellation of any enclosed operations, such as Activities and Timers.
- [withTimeout(timeoutMs, fn)](https://typescript.temporal.io/api/classes/workflow.CancellationScope#withtimeout): If a
timeout triggers before `fn` resolves, the scope is cancelled, triggering cancellation of any enclosed operations,
such as Activities and Timers.
- Equivalent to `new CancellationScope({ cancellable: true, timeout: timeoutMs }).run(fn)`.

Cancellations are applied to cancellation scopes, which can encompass an entire Workflow or just part of one.
Scopes can be nested, and cancellation propagates from outer scopes to inner ones.
A Workflow's `main` function runs in the outermost scope.
Cancellations are handled by catching `CancelledFailure`s thrown by cancelable operations.
Cancellations are applied to cancellation scopes, which can encompass an entire Workflow or just part of one. Scopes can
be nested, and cancellation propagates from outer scopes to inner ones. A Workflow's `main` function runs in the
outermost scope. Cancellations are handled by catching `CancelledFailure`s thrown by cancelable operations.

`CancellationScope.run()` and the static helpers mentioned earlier return native JavaScript promises, so you can use the familiar Promise APIs like `Promise.all` and `Promise.race` to model your asynchronous logic.
You can also use the following APIs:
`CancellationScope.run()` and the static helpers mentioned earlier return native JavaScript promises, so you can use the
familiar Promise APIs like `Promise.all` and `Promise.race` to model your asynchronous logic. You can also use the
following APIs:

- `CancellationScope.current()`: Get the current scope.
- `scope.cancel()`: Cancel all operations inside a `scope`.
- `scope.run(fn)`: Run an async function within a `scope` and return the result of `fn`.
- `scope.cancelRequested`: A promise that resolves when a scope cancellation is requested, such as when Workflow code calls `cancel()` or the entire Workflow is cancelled by an external client.
- `scope.cancelRequested`: A promise that resolves when a scope cancellation is requested, such as when Workflow code
calls `cancel()` or the entire Workflow is cancelled by an external client.

When a `CancellationScope` is cancelled, it propagates cancellation in any child scopes and of any cancelable operations created within it, such as the following:
When a `CancellationScope` is cancelled, it propagates cancellation in any child scopes and of any cancelable operations
created within it, such as the following:

- Activities
- Timers (created with the [sleep](https://typescript.temporal.io/api/namespaces/workflow#sleep) function)
- [Triggers](https://typescript.temporal.io/api/classes/workflow.Trigger)

### CancelledFailure

Timers and triggers throw [CancelledFailure](https://typescript.temporal.io/api/classes/common.CancelledFailure) when cancelled; Activities and Child Workflows throw `ActivityFailure` and `ChildWorkflowFailure` with cause set to `CancelledFailure`.
One exception is when an Activity or Child Workflow is scheduled in an already cancelled scope (or Workflow).
In this case, they propagate the `CancelledFailure` that was thrown to cancel the scope.
Timers and triggers throw [CancelledFailure](https://typescript.temporal.io/api/classes/common.CancelledFailure) when
cancelled; Activities and Child Workflows throw `ActivityFailure` and `ChildWorkflowFailure` with cause set to
`CancelledFailure`. One exception is when an Activity or Child Workflow is scheduled in an already cancelled scope (or
Workflow). In this case, they propagate the `CancelledFailure` that was thrown to cancel the scope.

To simplify checking for cancellation, use the [isCancellation(err)](https://typescript.temporal.io/api/namespaces/workflow#iscancellation) function.
To simplify checking for cancellation, use the
[isCancellation(err)](https://typescript.temporal.io/api/namespaces/workflow#iscancellation) function.

### Internal cancellation example

<!--SNIPSTART typescript-cancel-a-timer-from-workflow-->
[packages/test/src/workflows/cancel-timer-immediately.ts](https://github.com/temporalio/sdk-typescript/blob/main/packages/test/src/workflows/cancel-timer-immediately.ts)
```ts
import { CancelledFailure, CancellationScope, sleep } from '@temporalio/workflow';
import { CancellationScope, CancelledFailure, sleep } from '@temporalio/workflow';

export async function cancelTimer(): Promise<void> {
// Timers and Activities are automatically cancelled when their containing scope is cancelled.
Expand All @@ -84,7 +95,7 @@ Alternatively, the preceding can be written as the following.
<!--SNIPSTART typescript-cancel-a-timer-from-workflow-alternative-impl-->
[packages/test/src/workflows/cancel-timer-immediately-alternative-impl.ts](https://github.com/temporalio/sdk-typescript/blob/main/packages/test/src/workflows/cancel-timer-immediately-alternative-impl.ts)
```ts
import { CancelledFailure, CancellationScope, sleep } from '@temporalio/workflow';
import { CancellationScope, CancelledFailure, sleep } from '@temporalio/workflow';

export async function cancelTimerAltImpl(): Promise<void> {
try {
Expand Down Expand Up @@ -112,7 +123,7 @@ The following code shows how to handle Workflow cancellation by an external clie
<!--SNIPSTART typescript-handle-external-workflow-cancellation-while-activity-running-->
[packages/test/src/workflows/handle-external-workflow-cancellation-while-activity-running.ts](https://github.com/temporalio/sdk-typescript/blob/main/packages/test/src/workflows/handle-external-workflow-cancellation-while-activity-running.ts)
```ts
import { CancellationScope, proxyActivities, isCancellation } from '@temporalio/workflow';
import { CancellationScope, isCancellation, proxyActivities } from '@temporalio/workflow';
import type * as activities from '../activities';

const { httpPostJSON, cleanup } = proxyActivities<typeof activities>({
Expand Down Expand Up @@ -153,8 +164,8 @@ export async function nonCancellable(url: string): Promise<any> {

### withTimeout example

A common operation is to cancel one or more Activities if a deadline elapses.
`withTimeout` creates a `CancellationScope` that is automatically cancelled after a timeout.
A common operation is to cancel one or more Activities if a deadline elapses. `withTimeout` creates a
`CancellationScope` that is automatically cancelled after a timeout.

<!--SNIPSTART typescript-multiple-activities-single-timeout-workflow-->
[packages/test/src/workflows/multiple-activities-single-timeout.ts](https://github.com/temporalio/sdk-typescript/blob/main/packages/test/src/workflows/multiple-activities-single-timeout.ts)
Expand Down Expand Up @@ -208,8 +219,9 @@ export async function resumeAfterCancellation(url: string): Promise<any> {

### Cancellation scopes and callbacks

Callbacks are not particularly useful in Workflows because all meaningful asynchronous operations return promises.
In the rare case that code uses callbacks and needs to handle cancellation, a callback can consume the `CancellationScope.cancelRequested` promise.
Callbacks are not particularly useful in Workflows because all meaningful asynchronous operations return promises. In
the rare case that code uses callbacks and needs to handle cancellation, a callback can consume the
`CancellationScope.cancelRequested` promise.

<!--SNIPSTART typescript-cancellation-scopes-with-callbacks-->
[packages/test/src/workflows/cancellation-scopes-with-callbacks.ts](https://github.com/temporalio/sdk-typescript/blob/main/packages/test/src/workflows/cancellation-scopes-with-callbacks.ts)
Expand All @@ -236,7 +248,7 @@ You can achieve complex flows by nesting cancellation scopes.
<!--SNIPSTART typescript-nested-cancellation-scopes-->
[packages/test/src/workflows/nested-cancellation.ts](https://github.com/temporalio/sdk-typescript/blob/main/packages/test/src/workflows/nested-cancellation.ts)
```ts
import { CancellationScope, proxyActivities, isCancellation } from '@temporalio/workflow';
import { CancellationScope, isCancellation, proxyActivities } from '@temporalio/workflow';

import type * as activities from '../activities';

Expand All @@ -262,8 +274,8 @@ export async function nestedCancellation(url: string): Promise<void> {

### Sharing promises between scopes

Operations like Timers and Activities are cancelled by the cancellation scope they were created in.
Promises returned by these operations can be awaited in different scopes.
Operations like Timers and Activities are cancelled by the cancellation scope they were created in. Promises returned by
these operations can be awaited in different scopes.

<!--SNIPSTART typescript-shared-promise-scopes-->
[activities-cancellation-heartbeating/src/cancellation-scopes.ts](https://github.com/temporalio/samples-typescript/blob/main/activities-cancellation-heartbeating/src/cancellation-scopes.ts)
Expand Down Expand Up @@ -304,17 +316,20 @@ export async function shieldAwaitedInRootScope(): Promise<any> {

## Cancel an Activity from a Workflow {#cancel-an-activity}

Canceling an Activity from within a Workflow requires that the Activity Execution sends Heartbeats and sets a Heartbeat Timeout.
If the Heartbeat is not invoked, the Activity cannot receive a cancellation request.
When any non-immediate Activity is executed, the Activity Execution should send Heartbeats and set a [Heartbeat Timeout](/encyclopedia/detecting-activity-failures#heartbeat-timeout) to ensure that the server knows it is still working.
Canceling an Activity from within a Workflow requires that the Activity Execution sends Heartbeats and sets a Heartbeat
Timeout. If the Heartbeat is not invoked, the Activity cannot receive a cancellation request. When any non-immediate
Activity is executed, the Activity Execution should send Heartbeats and set a
[Heartbeat Timeout](/encyclopedia/detecting-activity-failures#heartbeat-timeout) to ensure that the server knows it is
still working.

When an Activity is canceled, an error is raised in the Activity at the next available opportunity.
If cleanup logic needs to be performed, it can be done in a `finally` clause or inside a caught cancel error.
However, for the Activity to appear canceled the exception needs to be re-thrown.
When an Activity is canceled, an error is raised in the Activity at the next available opportunity. If cleanup logic
needs to be performed, it can be done in a `finally` clause or inside a caught cancel error. However, for the Activity
to appear canceled the exception needs to be re-thrown.

:::note

Unlike regular Activities, [Local Activities](/local-activity) can be canceled if they don't send Heartbeats.
Local Activities are handled locally, and all the information needed to handle the cancellation logic is available in the same Worker process.
Unlike regular Activities, [Local Activities](/local-activity) can be canceled if they don't send Heartbeats. Local
Activities are handled locally, and all the information needed to handle the cancellation logic is available in the same
Worker process.

:::
6 changes: 3 additions & 3 deletions docs/encyclopedia/activities/activities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ This guide provides a comprehensive overview of Temporal Activities including
[Activity Definition](/activity-definition), [Activity Type](/activity-definition#activity-type),
[Activity Execution](/activity-execution), and [Local Activity](/local-activity).

An Activity is a normal function or method that executes a single, well-defined action, such as calling another service,
transcoding a media file, or sending an email message. An Activity can either be short or long-running. Activity code
can be non-deterministic. We recommend that it be [idempotent](/activity-definition#idempotency).
An Activity is a normal function or method that executes a single, well-defined action (either short or long running),
such as calling another service, transcoding a media file, or sending an email message. Activity code can be
non-deterministic. We recommend that it be [idempotent](/activity-definition#idempotency).

Workflow code orchestrates the execution of Activities, persisting the results. If an Activity Function Execution fails,
any future execution starts from initial state (except
Expand Down
Loading