In the Node SDK, Workflows are represented internally by a tree of scopes. The main function runs in the root scope.
Cancellation propagates from outer scopes to inner ones and is handled by catching
thrown by cancellable operations (see below).
CancellationScope is cancelled, it propagates cancellation in any child scopes and of any cancellable operations created within it, such as:
nonCancellable prevents cancellation from propagating to children#
cancelRequested may be awaited upon to make Workflow aware of cancellation while waiting on
Operations like timers and Activites are cancelled by the cancellation scope they were created in. Promises returned by these operations can be awaited in different scopes.
Callbacks are not particularly useful in Workflows because all meaningful asynchronous operations return Promises.
In the odd case that user code utilizes callbacks, CancellationScope.cancelRequested can be used to subscribe to cancellation.