Skip to content

Fix Standalone Activity Start-To-Close timeout bug#9901

Merged
dandavison merged 2 commits into
mainfrom
dan/saa-start-to-close-cancel-requested-bug
Apr 10, 2026
Merged

Fix Standalone Activity Start-To-Close timeout bug#9901
dandavison merged 2 commits into
mainfrom
dan/saa-start-to-close-cancel-requested-bug

Conversation

@dandavison
Copy link
Copy Markdown
Contributor

@dandavison dandavison commented Apr 10, 2026

What changed?

Change the validator of the Standalone Activity StartToCloseTimeout task so that it does not reject the task when in CANCEL_REQUESTED.

Why?

An accepted cancellation request should not prevent an activity from timing out normally (e.g. the activity may not be heartbeating, in which case the cancellation request is irrelevant). This is documented in the public API repo: https://github.com/temporalio/api/blob/master/temporal/api/enums/v1/activity.proto#L39-L41

How did you test it?

  • added new functional test(s)

Note

Medium Risk
Changes timeout validation for running/cancel-requested activities, which can affect when activities are marked timed out vs. remaining pending cancellation. Scope is small and covered by a new functional test.

Overview
Fixes a standalone activity edge case where StartToCloseTimeoutTask was being rejected once an activity entered CANCEL_REQUESTED, preventing the expected start-to-close timeout from firing.

Updates startToCloseTimeoutTaskHandler.Validate to accept tasks when status is either STARTED or CANCEL_REQUESTED, and adds a functional test (TestStartToCloseTimeout_WhileCancelRequested) asserting the activity still times out if the worker ignores cancellation.

Reviewed by Cursor Bugbot for commit c85616e. Bugbot is set up for automated code reviews on this repo. Configure here.

Pre-existing bug: StartToCloseTimeoutTask validator requires
status == STARTED, so it rejects the task when the activity is in
CANCEL_REQUESTED. The API contract (activity.proto) says START_TO_CLOSE
timeouts should still fire and block retries when cancellation has been
requested.
The validator only accepted STARTED, but a worker is still running in
CANCEL_REQUESTED state (it just hasn't acknowledged the cancellation).
The API contract (activity.proto) explicitly states that START_TO_CLOSE
timeouts should fire when cancellation is requested, blocking retries
and transitioning to TIMED_OUT.
@dandavison dandavison requested a review from fretz12 April 10, 2026 03:00
@dandavison dandavison requested review from a team as code owners April 10, 2026 03:00
@dandavison dandavison requested a review from spkane31 April 10, 2026 03:00
@dandavison dandavison merged commit 76beb85 into main Apr 10, 2026
49 checks passed
@dandavison dandavison deleted the dan/saa-start-to-close-cancel-requested-bug branch April 10, 2026 03:31
stephanos pushed a commit that referenced this pull request Apr 13, 2026
## What changed?
Change the validator of the Standalone Activity StartToCloseTimeout task
so that it does not reject the task when in `CANCEL_REQUESTED`.

## Why?
An accepted cancellation request should not prevent an activity from
timing out normally (e.g. the activity may not be heartbeating, in which
case the cancellation request is irrelevant). This is documented in the
public API repo:
https://github.com/temporalio/api/blob/master/temporal/api/enums/v1/activity.proto#L39-L41

## How did you test it?
- [x] added new functional test(s)
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.

3 participants