Skip to content

Commit f6a75d7

Browse files
Document Nexus Operation Cancellation types in TS
1 parent 4696ab5 commit f6a75d7

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
@@ -316,15 +316,25 @@ Requesting cancellation of a Cancellation Scope results in requesting cancellati
316316
The Workflow itself defines the root Cancellation Scope.
317317
Requesting cancellation of the Workflow therefore propagates the cancellation request to all cancellable operations started by that workflow, including Nexus Operations.
318318

319-
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.
320-
An example demonstrating this can be found at our [nexus cancellation sample](https://github.com/temporalio/samples-typescript/tree/main/nexus-cancellation).
321-
322319
Only asynchronous operations can be canceled in Nexus, since cancellation is sent using an operation token.
323320
The Workflow or other resources backing the operation may choose to ignore the cancellation request.
324321

325-
Once the caller Workflow completes, the caller's Nexus Machinery will not make any further attempts to cancel operations that are still running.
322+
When a Nexus operation is started the caller can specify different cancellation types that will control how the caller reacts to cancellation:
323+
324+
- `ABANDON` - Do not request cancellation of the operation.
325+
- `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.
326+
- `WAIT_CANCELLATION_REQUESTED` ` Request cancellation of the operation and wait for confirmation that the request was received. Doesn't wait for actual cancellation.
327+
- `WAIT_CANCELLATION_COMPLETED` - Wait for operation completion. Operation may or may not complete as cancelled.
328+
329+
The default is `WAIT_CANCELLATION_COMPLETED`. Users can set a different option on the `StartNexusOperationOptions`.
330+
331+
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.
332+
326333
It's okay to leave operations running in some use cases.
327-
To ensure cancellations are delivered, wait for all pending operations to finish before exiting the Workflow.
334+
To ensure cancelations are delivered, wait for all pending operations to deliver their cancellation requests before exiting the Workflow.
335+
336+
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.
337+
An example demonstrating this can be found at our [nexus cancellation sample](https://github.com/temporalio/samples-typescript/tree/main/nexus-cancellation).
328338

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

0 commit comments

Comments
 (0)