Skip to content

Conversation

@yiminc
Copy link
Member

@yiminc yiminc commented Jan 24, 2026

Summary

  • Fix ScheduleToStart and ScheduleToClose timeouts to return RETRY_STATE_TIMEOUT instead of RETRY_STATE_NON_RETRYABLE_FAILURE
  • These schedule timeouts are server-enforced deadlines, not actual activity execution failures
  • The actual failure that caused retries is available in failure.Cause, which SDKs should surface to users

Test plan

  • Added unit tests for ScheduleToStart timeout returning RETRY_STATE_TIMEOUT
  • Added unit tests for ScheduleToClose timeout returning RETRY_STATE_TIMEOUT
  • Existing tests pass

Fixes: #3667

🤖 Generated with Claude Code

When an activity times out due to ScheduleToStart or ScheduleToClose
timeout, return RETRY_STATE_TIMEOUT instead of RETRY_STATE_NON_RETRYABLE_FAILURE.

These schedule timeouts are server-enforced deadlines, not actual activity
execution failures. The actual failure that caused retries (if any) is
available in failure.Cause, which SDKs should surface to users since it
represents the real failure.

This approach maintains backward compatibility while providing correct
semantics:
1. RETRY_STATE_TIMEOUT indicates a schedule timeout triggered the event
2. failure.Cause contains the last retry failure (existing behavior)
3. SDKs can check retry_state == TIMEOUT to surface failure.Cause

Fixes: temporalio#3667

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@yiminc yiminc force-pushed the fix-activity-timeout-retry-state branch from bb04733 to cff60d7 Compare January 24, 2026 18:39
…eout

TestActivityScheduleToClose_FiredDuringActivityRun now expects
RETRY_STATE_TIMEOUT instead of RETRY_STATE_NON_RETRYABLE_FAILURE
when a ScheduleToClose timeout fires during activity execution.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@yiminc yiminc marked this pull request as ready for review January 24, 2026 18:45
@yiminc yiminc requested review from a team as code owners January 24, 2026 18:45
@yiminc yiminc changed the title [WIP, DO_NOT_REVIEW] Fix activity timeout RetryState to return TIMEOUT for schedule timeouts Fix activity timeout RetryState to return TIMEOUT for schedule timeouts Jan 24, 2026
1. Preserve original timeout type when RETRY_STATE_TIMEOUT is returned

Previously, when RetryActivity returned RETRY_STATE_TIMEOUT, the timer
executor would overwrite the timeout type to SCHEDULE_TO_CLOSE. This was
based on the assumption that RETRY_STATE_TIMEOUT only occurred when the
expiration time was exceeded during retry backoff calculation.

With the fix to return RETRY_STATE_TIMEOUT for ScheduleToStart and
ScheduleToClose timeout types directly, this overwriting caused incorrect
timeout types to be recorded. For example, a ScheduleToStart timeout would
incorrectly show as ScheduleToClose in the activity timed out event.

The fix preserves the original timeout type from timerSequenceID.TimerType,
which accurately reflects which timer actually fired.

2. Fix testifylint errors: use require for error assertions

Change s.NoError(err) to s.Require().NoError(err) for error assertions
in retry activity tests to satisfy the testifylint linter.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Temporal Server returns incorrect RetryState in some cases of scheduleToClose timeout

2 participants