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 45b1d7e

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

Plumbs worker heartbeat interval into Core, replaces worker activity enablement with explicit task-type flags, and forwards plugin names to Core; updates native/worker APIs and tests accordingly.

  • Runtime/Core Bridge:
    • Add worker_heartbeat_interval_millis to config::RuntimeOptions; pass to RuntimeOptionsBuilder.heartbeat_interval(...).
    • Update runtime_new to accept and forward heartbeat interval; rename TS binding to newRuntime(runtimeOptions).
    • Map new errors: WorkflowNotEnabled/ActivityNotEnabled to UnexpectedError.
  • TypeScript Native Bindings:
    • native.RuntimeOptions gains workerHeartbeatIntervalMillis and is passed via newRuntime.
    • WorkerOptions now uses taskTypes (enableWorkflows, enableLocalActivities, enableRemoteActivities, enableNexus) and adds plugins: string[].
  • Worker (TS):
    • Add RuntimeOptions.workerHeartbeatInterval (ms or string); compiled to workerHeartbeatIntervalMillis (0 => disabled).
    • Compute and send taskTypes based on registered workflows/activities/nexus; enableRemoteActivities respects enableNonLocalActivities.
    • Forward plugin names to Core as PluginInfo.
  • Tests:
    • Update configs for newRuntime and workerHeartbeatIntervalMillis.
    • Replace enableNonLocalActivities usage with taskTypes in bridge tests; add test ensuring local activities run when non-local activities are disabled.

Written by Cursor Bugbot for commit 3eb05da. 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.

taskTypes: {
enableWorkflows,
enableLocalActivities,
enableRemoteActivities: opts.enableNonLocalActivities && opts.activities.size > 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

That's basically saying:

enableRemoteActivities: (enableWorkflows && opts.activities.size > 0) && opts.activities.size > 0

Which is incorrect. We don't need workflows to enable remote activities. I'm surprised tests passed with this.

telemetryOptions?: TelemetryOptions;

/**
* Interval for worker heartbeats. `null` disables heartbeating.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not totally comfortable using null as a user-facing marker to disable heartbeating. We do that internally at the bridge layer, to work around limitations of Node/NAPI/Neon, but I don't think we should do that in public APIs.

Instead, I suggest making this Duration | boolean, so false disables heartbeating, true or == null (which includes undefined) defaults to 60s, and anything else is parsed as a Duration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh ok, let's do 0 to disable heartbeating. This is what I was planning on doing in dotnet

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

3 participants