Skip to content

Conversation

@mfateev
Copy link
Member

@mfateev mfateev commented Jan 9, 2026

Summary

  • Add heartbeat timeout enforcement to the test environment (TestWorkflowEnvironment)
  • Activities that don't heartbeat within the configured HeartbeatTimeout now correctly fail with TimeoutTypeHeartbeat
  • Matches production Temporal server behavior where activities are failed if they don't heartbeat in time

Problem

The Go SDK test environment did not enforce heartbeat timeout for activities during unit testing. When an activity ran longer than the configured HeartbeatTimeout without sending heartbeats, the test would pass instead of failing.

Fixes #1282

Implementation

  • Added heartbeat monitoring goroutine in ExecuteActivity that checks for timeout
  • Modified mockHeartbeatFn to track last heartbeat time
  • Added heartbeatTimeoutResult type to signal heartbeat timeout failures
  • Modified handleActivityResult to convert heartbeat timeout to proper error

Test plan

  • Added Test_ActivityHeartbeatTimeout - activity without heartbeating times out
  • Added Test_ActivityHeartbeatTimeout_WithHeartbeat - activity with regular heartbeats succeeds
  • Added Test_ActivityHeartbeatTimeout_WithDetails - heartbeat details are preserved on timeout
  • All existing tests pass

@mfateev mfateev requested a review from a team as a code owner January 9, 2026 01:26
This fixes an issue where the test environment did not enforce heartbeat
timeout for activities. When an activity ran longer than HeartbeatTimeout
without sending heartbeats, the test would pass instead of failing with
a heartbeat timeout error.

Changes:
- Add heartbeat timeout tracking fields to testActivityHandle
- Start heartbeat monitoring goroutine when HeartbeatTimeout > 0
- Update lastHeartbeatTime when heartbeat is received
- Return TIMEOUT_TYPE_HEARTBEAT error when timeout occurs
- Add three new tests to verify the fix

Fixes temporalio#1282
@mfateev mfateev force-pushed the task/heartbeat-timeout-testing branch from ae8cf26 to 2c3a26f Compare January 9, 2026 18:08
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.

Heartbeat timeout not raised while testing

1 participant