Fix Standalone Activity Start-To-Close timeout bug#9901
Merged
Conversation
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.
Quinn-With-Two-Ns
approved these changes
Apr 10, 2026
5 tasks
fretz12
approved these changes
Apr 10, 2026
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?
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
StartToCloseTimeoutTaskwas being rejected once an activity enteredCANCEL_REQUESTED, preventing the expected start-to-close timeout from firing.Updates
startToCloseTimeoutTaskHandler.Validateto accept tasks when status is eitherSTARTEDorCANCEL_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.