Skip to content

Commit 3bcb769

Browse files
authored
docs: Improve documentation for activity heartbeat and cancellationSignal (#1151)
1 parent c60dc29 commit 3bcb769

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/activity/src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,11 @@ export class Context {
230230
* An {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal | `AbortSignal`} that can be used to react to
231231
* Activity cancellation.
232232
*
233-
* Used by {@link https://www.npmjs.com/package/node-fetch#request-cancellation-with-abortsignal | fetch} to abort an
233+
* This can be passed in to libraries such as
234+
* {@link https://www.npmjs.com/package/node-fetch#request-cancellation-with-abortsignal | fetch} to abort an
234235
* in-progress request and
235236
* {@link https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options child_process}
236-
* to abort a child process, and is supported by some other libraries as well.
237+
* to abort a child process, as well as other built-in node modules and modules found on npm.
237238
*
238239
* @see [Cancellation](/api/namespaces/activity#cancellation)
239240
*/
@@ -288,7 +289,13 @@ export class Context {
288289
*
289290
* Calling `heartbeat()` from a Local Activity has no effect.
290291
*
292+
* The SDK automatically throttles heartbeat calls to the server with a duration of 80% of the specified activity
293+
* heartbeat timeout. Throttling behavior may be customized with the `{@link maxHeartbeatThrottleInterval | https://typescript.temporal.io/api/interfaces/worker.WorkerOptions#maxheartbeatthrottleinterval} and {@link defaultHeartbeatThrottleInterval | https://typescript.temporal.io/api/interfaces/worker.WorkerOptions#defaultheartbeatthrottleinterval} worker options.
294+
*
291295
* Activities must heartbeat in order to receive Cancellation (unless they're Local Activities, which don't need to).
296+
*
297+
* :warning: Cancellation is not propagated from this function, use {@link cancelled} or {@link cancellationSignal} to
298+
* subscribe to cancellation notifications.
292299
*/
293300
public heartbeat(details?: unknown): void {
294301
this.heartbeatFn(details);

0 commit comments

Comments
 (0)