Skip to content

Commit 5e53914

Browse files
Document Nexus Operation Cancellation types in TS (#4228)
Co-authored-by: Jwahir Sundai <jwahir.sundai@temporal.io>
1 parent f99eccc commit 5e53914

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

docs/develop/typescript/temporal-nexus.mdx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,25 @@ Requesting cancellation of a Cancellation Scope results in requesting cancellati
326326
The Workflow itself defines the root Cancellation Scope.
327327
Requesting cancellation of the Workflow therefore propagates the cancellation request to all cancellable operations started by that workflow, including Nexus Operations.
328328

329-
To provide more granular control over cancellation of a specific Nexus Operation, you may explicitly create a new Cancellation Scope, and start the Nexus Operation from within that scope.
330-
An example demonstrating this can be found at our [nexus cancellation sample](https://github.com/temporalio/samples-typescript/tree/main/nexus-cancellation).
331-
332329
Only asynchronous operations can be canceled in Nexus, since cancellation is sent using an operation token.
333330
The Workflow or other resources backing the operation may choose to ignore the cancellation request.
334331

335-
Once the caller Workflow completes, the caller's Nexus Machinery will not make any further attempts to cancel operations that are still running.
332+
When a Nexus operation is started the caller can specify different cancellation types that will control how the caller reacts to cancellation:
333+
334+
- `ABANDON` - Do not request cancellation of the operation.
335+
- `TRY_CANCEL` - Initiate a cancellation request and immediately report cancellation to the caller. Note that this type doesn't guarantee that cancellation is delivered to the operation handler if the caller exits before the delivery is done.
336+
- `WAIT_CANCELLATION_REQUESTED` ` Request cancellation of the operation and wait for confirmation that the request was received. Doesn't wait for actual cancellation.
337+
- `WAIT_CANCELLATION_COMPLETED` - Wait for operation completion. Operation may or may not complete as cancelled.
338+
339+
The default is `WAIT_CANCELLATION_COMPLETED`. Users can set a different option on the `StartNexusOperationOptions`.
340+
341+
Once the caller Workflow completes, the caller's Nexus Machinery stops attempting to cancel operations that have not yet been canceled, letting them run to completion.
342+
336343
It's okay to leave operations running in some use cases.
337-
To ensure cancellations are delivered, wait for all pending operations to finish before exiting the Workflow.
344+
To ensure cancelations are delivered, wait for all pending operations to deliver their cancellation requests before exiting the Workflow.
345+
346+
To provide more granular control over cancellation of a specific Nexus Operation, you may explicitly create a new Cancellation Scope, and start the Nexus Operation from within that scope.
347+
An example demonstrating this can be found at our [nexus cancellation sample](https://github.com/temporalio/samples-typescript/tree/main/nexus-cancellation).
338348

339349
## Make Nexus calls across Namespaces in Temporal Cloud {#nexus-calls-across-namespaces-temporal-cloud}
340350

0 commit comments

Comments
 (0)