Skip to content

Conversation

@yuandrew
Copy link
Contributor

@yuandrew yuandrew commented Oct 29, 2025

What was changed

  • Plumb the ability to enable/disable worker heartbeating to TS lang layer
  • plumb plugin names to Core, to show in worker heartbeats
  • specify WorkerTaskTypes based on if workflows/activities/nexus handlers are registered to the worker
  • bumped sdk-core to 44a6576

Why?

New feature!

Checklist

  1. Closes [Feature Request] Enable Worker Heartbeating #1810

  2. How was this tested:

Manually tested that heartbeats with a simple plugin from the worker and client both show up in plugins section of the worker heartbeat.

Also tested setting workerHeartbeatInterval: null disables heartbeating for the worker

  1. Any docs updates needed?

Note

Adds runtime-configurable worker heartbeats, forwards plugin names in worker heartbeats, introduces task-type gating, and migrates client TLS/options to new Core APIs.

  • Runtime/Core-bridge:
    • Add worker_heartbeat_interval_millis runtime option; plumb through to Core heartbeat_interval.
  • Worker:
    • Introduce WorkerTaskTypes and wire to Core (task_types), replacing enableNonLocalActivities for capability gating.
    • Forward plugins to Core as PluginInfo set for inclusion in heartbeats.
    • Map “not enabled” completion errors for workflows/activities/nexus to UnexpectedError.
  • Client:
    • Migrate TLS config/types (TlsOptions, client_tls_options) and switch to new Core builders (maybe_* setters).
  • TypeScript bindings:
    • Update native.ts interfaces to new TLS, runtime, and worker options.
  • Tests:
    • Adjust TLS error expectations and add test ensuring local activities work with remote activities disabled.
    • Include runtime option workerHeartbeatIntervalMillis in bridge tests.

Written by Cursor Bugbot for commit fabb505. This will update automatically on new commits. Configure here.

@yuandrew yuandrew changed the title Enable Worker heartbeating Enable Worker heartbeating, plumb plugin names to core, update Core to 45b1d7e Nov 27, 2025
@yuandrew yuandrew marked this pull request as ready for review November 27, 2025 02:05
@yuandrew yuandrew requested a review from a team as a code owner November 27, 2025 02:05
Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only required change is fixing up tests. Rest are light suggestions or questions.

}
}
CompleteWfError::WorkflowNotEnabled => {
BridgeError::UnexpectedError(format!("{err}"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinions on this 🤷

Suggested change
BridgeError::UnexpectedError(format!("{err}"))
BridgeError::UnexpectedError(err.to_string())

.into_iter()
.map(|name| PluginInfo {
name,
version: String::new(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my own knowledge, is version from the past or not yet implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I don't know. haha. The API was originally implemented with version, but not sure what the intent was. Will follow up on this.

@yuandrew yuandrew requested a review from mjameswh December 4, 2025 00:55
max_activities_per_second: Option<f64>,
max_task_queue_activities_per_second: Option<f64>,
shutdown_grace_time: Option<Duration>,
plugins: Vec<String>,
Copy link
Member

@cretz cretz Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider deduping plugins if we don't already. Depending on plugin implementation, it may be very normal to configure multiple of the same plugin on the same worker (maybe each has different settings).

This should be done in every SDK IMO too if we don't already (could consider making that Vec a Set on the Core side).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, a set would ensure deduping. Created temporalio/sdk-core#1072

const { metrics, noTemporalPrefixForMetrics } = options.telemetryOptions ?? {}; // eslint-disable-line deprecation/deprecation
const [logger, logExporter] = compileLoggerOptions(options);

const heartbeatMillis = msToNumber(options.workerHeartbeatInterval ?? '60s');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing validation for heartbeat interval range

The documentation for workerHeartbeatInterval states "Accepted range is between 1s and 60s" but the implementation at line 378 doesn't validate this range. The code only checks if the value is 0 (to disable heartbeating) but accepts any other value without validation. Users could pass invalid values like 100ms or 2m which would be silently accepted, potentially causing unexpected behavior in worker heartbeating.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enforced in core

@yuandrew yuandrew changed the title Enable Worker heartbeating, plumb plugin names to core, update Core to 45b1d7e Enable Worker heartbeating, plumb plugin names to core, update Core to 44a6576 Dec 9, 2025
@mjameswh
Copy link
Contributor

@yuandrew I see you renamed some bridge struct fields, but then reverted due to build issues.

I would have kept it, but rename the corresponding TS side structures. The bridge layer only uses internal types, never directly linked to user facing APIs, so no risk.

See https://github.com/temporalio/sdk-typescript/tree/pr/yuandrew/1818-mjameshwh-additions.

Copy link
Contributor

@mjameswh mjameswh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@yuandrew yuandrew merged commit ff60e74 into temporalio:main Dec 17, 2025
52 of 53 checks passed
@yuandrew yuandrew deleted the worker-heartbeat branch December 17, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Enable Worker Heartbeating

4 participants